Working With External Data Sources

Applies to TestComplete 14.92, last modified on September 16, 2021

It is often necessary to read data from external files, for example, to compare them with the test data or to use them during data-driven testing. TestComplete provides the ability to read data of various formats from external files.

In This Section

Reading Text Files

Describes how to retrieve data from text files.

Working With XML Files From Scripts

Describes how to retrieve data from and store data to XML files.

Working With PDF Files

Describes how to retrieve data from PDF files.

Working with Microsoft Excel Files

Describes the approaches to retrieving data from Excel files.

Working With Databases

Explains how to connect to the needed database and use its data for testing.

Working With Files From Scripts

Describes how to work with files from tests.

For general information on reading data from files, see the sections below:

Text Files

For more information, see Reading Text Files.

Binary Files

You can work with binary files in the same way as with text files:

  • You can use DelphiScript native file routines.

  • You can use the Scripting.FileSystemObject object.

  • You can use program objects provided by TestComplete:aqFile and aqBinaryFile.

For more information, see above.

INI Files

To read INI files, you can use the Storages.INI object. It provides access to a root section of the INI file. Using the object, you can work with the file’s current section, subsections and their options.

For more information, see Storages Object.

Windows System Registry

You can read sections and options stored in the Windows system registry. To do this, use the Storages.Registry method. This method returns the Section object for a system registry key. Using the object, you can create and delete sections, subsections and their options and change the section contents.

For more information, see Reading Sections and Options from the System Registry. Example.

XML Files

There are two different ways to read data from XML files:

  • By using the Storages object. This approach is applicable only to XML files of a specific format.

  • By using the XML DOM object (recommended). It allows reading data from XML files of any format. The object provides scripting access to an XML document and to all of its elements and attributes via the COM interface.

For more information, see Working With XML Files From Scripts.

CSV Files

To read data from CSV files in keyword tests, you can use DB Table variables. These variables can store links to CSV files and provide serial access to data rows stored in these files. Usually, you use DBTable variables in Data-Driven Loops to iterate through file lines. See Creating Data-Driven Loops and Data-Driven Testing With Keyword Tests - Tutorial.

To read data from CSV files in scripts, use the DDT.CSVDriver object that provides scripting access to CSV files. The driver represents the stored data as a table and allows iterating through the file lines and read data from it. For more information, see Using DDT Drivers.

Microsoft Office Excel Files

To read data from Microsoft Office Excel files in keyword tests, you can use DB Table variables. These variables can store links to Excel files and provide serial access to data rows stored in these files. Usually, you use these variables in Data-Driven Loops to iterate through file rows. To learn more, see Creating Data-Driven Loops and Data-Driven Testing With Keyword Tests - Tutorial.

To read data from Microsoft Office Excel files in scripts, use the DDT.ExcelDriver object. The driver represents the stored data as a table and allows iterating through the file rows and reading cell values. For more information, see Using DDT Drivers.

Databases

If your tested application uses the Microsoft Active Data Object to manage databases, you can access the data stored in the database:

  • By using DB Table variables. These variables can store links to database tables and queries and provide serial access to their records. You usually use these variables in Data-Driven Loop to iterate through the table records.

    To learn more, see Creating Data-Driven Loops and Data-Driven Testing With Keyword Tests - Tutorial.

  • By using the DDT.ADODriver object that provides scripting access to database tables. The driver object represents the stored data as a table. The object allows iterating through the table or recordset and reading the field values. For more information, see Using DDT Drivers.

  • Using the ADO program object. The object allows connecting to a database, creating tables and datasets and working with records and queries. For more information, see Working With Databases.

See Also

Data-Driven Testing
Working With Files From Scripts
Reading Text Files
Working With XML Files From Scripts
CSVDriver Method
ExcelDriver Method
Working With Databases
Storages Object

Highlight search results