Creating Data-Driven Loops

Applies to TestComplete 15.31, last modified on March 17, 2022

In TestComplete, you can create data-driven loops from scripts and keyword tests by using DDT driver objects. For more information about using these objects, see Using DDT Drivers. Besides, TestComplete provides a special Data-Driven Loop operation that helps you organize data-driven loops in keyword tests. You can add this operation to your test in any of the following ways:

  • By selecting the Make Data Loop context menu command. Using this command, you can create data-driven loops easily and quickly. For detailed information, see below.

-- or --

  • By dragging the Data-Driven Loop operation from the Operations panel to your keyword test. You can also specify a set of child operations that will be executed in a loop. For more information, see below.

Using the Make Data Loop Command

Below, are step-by-step instructions on creating a data-driven loop in your keyword test:

  1. Open your keyword test for editing.

  2. Select the operations to be executed in a loop.

  3. Right-click the selected operations and choose Make Data Loop from the context menu.

    Selecting Make Data Loop command
  4. TestComplete will display the Data-Driven Loop wizard. On the first page of this wizard, you need to specify the name of the DB Table or Table variable that will provide access to the needed stored data. Note that you can either specify the name of an existing DB Table or Table variable, or create a new variable with the needed name. If you choose to create a new variable, TestComplete will display additional pages that depend on the variable type (DB Table or Table).

    If you select to create a DB Table variable, you then will specify the type of the needed data storage (an Excel file, a CSV file or a database table) and the records to be processed during the test run.

    If you choose to create a Table variable, you will enter the data manually or generate it using the TestComplete Data Generator. After that, you will have to define the set of rows to be processed during the test run.

  5. The Update Values page of the wizard lists the parameters that the selected operations use. On this page, you can assign data the selected variable stores to the parameters.

    Parameters that do not have data assigned have [Use hard-coded value] in their Value column.

    To assign data to a parameter, click the Value cell and select the needed column of the DB Table or Table variable from the drop-down list.

    If the name of the parameter coincides with the name of the data source’s column, the wizard will assign the appropriate column to the parameter automatically.

    Updating Parameter's Value
  6. Click Finish to close the wizard.

  7. After closing the wizard, TestComplete will add the Data-Driven Loop operation to the keyword test, and all the selected operations will be moved as its child operations.

    Data-Driven Loop operation

Using the Data-Driven Loop Operation

Below, are step-by-step instructions on creating a data-driven loop in your keyword test:

  1. Open your keyword test for editing.

  2. Drag the Data-Driven Loop operation from the Operations panel to your test. The Data-Driven Loop wizard will appear.

  3. Follow the wizard instructions to create a new DB Table or Table variable (or select an existing one) that will provide access to the needed data. For more information on this and for a description of all wizard pages, see the the operation description.

    Note: The wizard will not display the Update Values page where you can assign values to data. You will do this later. See below.
  4. After you add the Data-Driven Loop operation to your keyword test, you will need to manually move all the operations that you want to execute in a data-driven loop to the list of child operations of the Data-Driven Loop operation.

    You can do this either by dragging the operations to the desired location or by using the arrows at the top of the Keyword Test editor. Only those operations that have been moved to the list of the Data-Driven Loop operation’s child operations will be executed in the data-driven loop.

  5. After you add the desired operation to the Data-Driven Loop operation’s child operations, update the values of operation parameters manually:

    • Double-click the operation whose hard-coded parameter you want to replace with data retrieved from the created variable.

    • In the resulting wizard, update the needed parameter. To change the parameter value, click the ellipsis button in the Value cell and select Table Data from the Mode drop-down list. In the Value drop-down list, select the variable you specified earlier and the needed column:

      Editing Parameter Value
  6. Update parameters of other operations in the data-driven loop.

Adding Operations to an Existing Data-Driven Loop

If your test already has a data-driven loop, you can add new operations to that loop. You can do this either by selecting the needed operation and using the arrows at the top of the editor to change its location, or by dragging the operation to the data-driven loop.

In order for the added operation to use values from the data storage, assign the needed DB Table or Table variable to the operation’s parameter manually:

  • Double-click the added operation.

  • In the resulting wizard, update the needed parameter. To change the parameter value, click the ellipsis button in the Value cell and select Table Data from the Mode drop-down list. In the Value drop-down list, select the variable and the needed column.

For more information explaining how to create data-driven loops in keyword tests, see Data-Driven Testing With Keyword Tests - Tutorial.

See Also

Data-Driven Loop Operation
Variables of the DB Table Type
Data Generator Wizard

Highlight search results