Data-Driven Loop Operation

Applies to TestComplete 15.62, last modified on March 19, 2024

Description

Use the Data-Driven Loop operation to create data-driven loops in your keyword tests. The operation allows you to get access to a data storage and iterate through data records.

To add the operation to your test, do any of the following:

  • Select the operations to be executed in a loop, right-click them and choose the Make Data Loop item from the ensuing context menu. In this case, TestComplete will add the Data-Driven Loop operation to your keyword test and move all the selected operations as its child operations. For more information, see Creating Data-Driven Loops.

– or –

  • Drag the operation from the Operations panel to the Keyword Test editor. After that, TestComplete displays the Data-Driven Loop wizard where you can specify the data source and the rows that will be processed by the operation.

Requirements

To access data in Excel files, you must have Microsoft Office 12.0 Access Database Engine OLE DB Provider installed on your computer. Make sure the “bitness” of this data provider (32- or 64-bit) is the same the TestComplete “bitness”, otherwise, you will get the “The needed data source driver is not installed...” error message. To learn more, see Microsoft Office Excel Data Connectivity.

Operation Result

The operation does not return any value.

Scripting Analogue

Scripting analogues of this operation are the methods of the DDT object. For more information on creating data-driven tests in scripts, see Using DDT Drivers.

Child Operations

The operation can have any other operation (or operations) as a child.

Operation Parameters

When you add the operation to your keyword test, TestComplete displays a wizard that lets you specify these parameters. To modify parameters of an operation that is already added to the test, you can use special dialogs and in-place editors provided by the Keyword Test editor.

Specifying Parameters When Adding the Operation

The Data-Driven Loop wizard contains the following pages:

Select Table Variable

On this page, you specify a variable of the DB Table or Table type that will provide access to the data. You can either create a new variable, or specify an existing one. DB Table variables provide you with the functionality needed to read data from Excel and CSV files and from database tables and queries. Each DB Table variable contains a link to the data storage and provides access to its rows and columns. Table variables store data in the form of two-dimensional arrays. They provide access to this data.

To create a new variable, select the Create new variable item and enter the needed name in the edit box below. If the entered name coincides with the name of an existing variable, TestComplete will display a message informing you that this name cannot be used. In this case, enter another variable name.

To select an existing variable of the DB Table or Table type, select the Use existing variable item and choose the needed variable in the tree below.

Select Table Kind

On this page, you can choose the type of the used data storage. Possible variants are as follows:

  • Excel worksheet – Select this item to use an Excel worksheet as a data storage.
  • CSV file – Select this item to use a CSV file as a data storage.
  • Database table – Select this item to use a database table as a data storage.
  • Database query – Select this item to specify a query to a database and use its result as a data storage.
  • Table variable – Select this item to use a Table variable as a data storage.

If the Excel worksheet type is selected, the Select Excel Workbook and Select Excel Worksheet pages appear. On these pages, you can specify the name of the Excel file (.xls or .xlsx) and choose any worksheet whose data will be retrieved by the DB table variable.

If the CSV file type is selected, the Select CSV File and CSV Format Parameters pages appear. On these pages, you can specify a CSV file (.txt or .csv) and specify format parameters for it.

If the Database table type is selected, the Specify Database Connection Settings and Select Table pages appear. On these pages, you can specify connection settings, the account under which you will connect to the needed database and the name of the table that will be used as a data storage.

If the Database query type is selected, the Specify Database Connection Settings and Specify Query pages appear. On these pages, you can specify the connection settings and the desired query to be used to retrieve data from the database.

If the Table variable type is selected, the Table generation and Variable’s default value pages appear.

Note: The Table generation page appears only if you create a new table variable and fill it with new data. Otherwise, the Variable’s default value page is only available.

On the Table generation page, you can specify settings for the data that will be generated and written to the variable. For this purpose, click Add and then select Generate from the drop-down list in the Data Type column. After that, click the ellipsis button in the Value or Settings column. The Generate Data dialog will appear.

Tip: You can also specify a value for the Table variable manually. To do this, select Use value in the Data Type column and enter the desired value in the Value or Settings column.

On the Variable’s default value page, you can review the data that is written to the variable. This page corresponds to the Table variable editor that is integrated into the operation’s wizard. For more information on this editor, see Working With the Table Variable Editor.

Tip: You can also use this page to modify table records and other settings. Use the Columns and Rows boxes to specify the needed size of the data storage. To generate the data and fill the column with it, select any cell of the target column and click . After that, the Generate Data dialog will appear, and you will be offered to specify the generation options. Specify these and click OK. After that, the selected column will be filled with the generated data.
Select Records

On this page, you can specify the records from the needed data storage which will be processed by the Data-Driven Loop operation. By default, the operation processes all records of the specified storage. If you want to specify the start and end records for processing, enter their identifiers into the From Record and To Record edit boxes respectively.

Update Values

This page is available only if you call the Data-Driven Loop wizard from a keyword test using the Make Data Loop command (select operations in the test, right-click them and then click Make Data Loop).

The Update Value page lists the parameters that the selected operations use. On this page, you can update these parameters.

Parameters whose values are not updated have [Use hard-coded value] in their Value column.

To update a parameter, select the needed column of the data storage from the Value list.

Parameters whose names coincide with the data storage’s column are updated automatically.

To learn more about creating data-driven loops via the Make Data Loop command, see Creating Data-Driven Loops.

Modifying Parameters

After adding the operation to the test, you can modify the operation’s parameters via the same wizard as you used to add the operation. To invoke the wizard, simply double-click the operation’s row in the Keyword Test editor.

To modify parameters of the operation, you can also use the in-place editors and dialogs provided by the Keyword Test editor.

Remarks

Each column of a data storage has its own identifier which is shown in the Value combo box of the Edit Parameter dialog.

  • If you use a variable of the Table type, the column names coincide with the column names of the variable’s table.

  • If you use a DB Table variable, the column names depend on the data source type:

    • For Excel files, the identifiers are:

      • F1 – For the first column
      • F2 – For the second column, and so on

      For information on specifics of retrieving data from Excel sheets, see Using Excel Files as Data Storages.

    • For CSV files, column identifiers are specified in the first row of the file if the First row contains column names option is enabled. If the option is disabled, the identifiers are:

      • F1 – For the first column
      • F2 – For the second column, and so on

      For information on the specifics of using CSV files and retrieving data from them, see Using CSV Files as Data Storages.

    • For the database type, the names of the table’s columns are treated as identifiers. For more information on specifics of using databases and retrieving data from them, see Using Database Table as Data Storages.

For more information explaining how to use the Data-Driven Loop operation in tests, see Creating Data-Driven Loops and Data-Driven Testing With Keyword Tests - Tutorial.

See Also

Data Access
Specifying Operation Parameters
Variables of the DB Table Type
Creating Data-Driven Loops
Data-Driven Testing With Keyword Tests - Tutorial
About Keyword Test Editor
Data Generator Wizard

Highlight search results