Using CSV Files as Data Storages

Applies to TestComplete 15.63, last modified on April 10, 2024

One of the popular data storage for data-driven tests is files that store comma-separated values. TestComplete supports this type of storage and allows you to retrieve data from it.

To access data stored in CSV files, you can use DB Table variables. These variables are used by the Data-Driven Loop operation that allows you to iterate through the storage’s records in keyword tests. See Creating Data-Driven Loops and Data-Driven Testing With Keyword Tests - Tutorial.

TestComplete also provides the CSVDriver object that simplifies retrieving data from it in your scripts (see DDT.CSVDriver and Using DDT Drivers).

Requirements

To retrieve data from CSV files, TestComplete uses the following drivers:

  • 32-bit version of TestComplete: the Microsoft Jet Engine driver.

  • 64-bit version of TestComplete: Microsoft Office 12.0 Access Database Engine OLE DB Provider (data provider or driver). If you have the 64-bit version of Microsoft Office 2010 or later on your computer, then, most likely, you have the provider. Otherwise, you will have to install it. The provider is part of Microsoft Access Database Engine 2010 Redistributable x64. You can download the installation package from the Microsoft website:

    https://www.microsoft.com/en-us/download/details.aspx?id=13255

If you have 32-bit Microsoft Office 2010, the installation of the 64-bit provider will fail. In this case, perform the following steps to install it:

Show Steps

Specifics

  • The object assumes that each row in your CSV file contains data for one test run. Files that use multiple rows for one run are not supported.

  • The column names are specified by the first line of the file.

  • The format of the CSV file is determined by using a schema information file, named Schema.ini, and located in the same folder as the CSV file. Schema.ini can keep information about several files and for each file it provides data for the general format of the file, field names and field types, used character set, delimiter character, and a number of other data characteristics. For example:

    // The contents of the Schema.ini
    [DDT_Info.csv]
    Format=Delimited(;)
    CharacterSet=ANSI

    To read more about the structure of this file, refer to the Schema.ini File (Text File Driver) article in the MSDN Library.

  • When the Schema.ini file is not found the format of the CSV file is defined by the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Text registry settings. For instance, the delimiter character is specified by the Format key and can have one of the following values: TabDelimited, CSVDelimited, Delimited(custom_character), FixedLength.

  • The Jet Engine has a limitation of 64 connections per process. So, after your test finishes with a CSV file, it is recommended that you close the connection by calling the DDT.CloseDriver method.

Tip: You can view and edit your CSV files directly in the TestComplete Code Editor. To do this, simply drag the desired file to the TestComplete Workspace. The file will be opened for editing. Pressing Save All will save the changes made to the file.

See Also

Data-Driven Testing
Data-Driven Testing - Basic Concepts
Preparing Data for Data-Driven Testing
Organizing Data Storages
Using Keyword Tests for Data-Driven Testing
Creating Data-Driven Loops
Data-Driven Testing With Keyword Tests - Tutorial
Using Scripts for Data-Driven Testing
Using DDT Drivers
CSVDriver Method

Highlight search results