4. Modifying Recorded Test

Applies to TestComplete 15.47, last modified on January 20, 2023

Now, we can modify the recorded test to add a new order and check the order information generated by the application using the data storage. To do this, we will add the Data-Driven Loop operation to the recorded keyword test. This simplifies the process of connecting to the data storage and iterating through it.

Using the Data-Driven Loop operation, we will create a data-driven loop in the test and move the operations that create an order and verify the output values of the Order form to this loop. The Data-Driven Loop operation will call the specified keyword operations in a loop for each portion of data that the operation reads from the data storage.

To create a data-driven loop:

  1. Click the first comment in the test (it looks like Start creating an order). Press SHIFT and click the last comment in the test (Finish creating an order). Thus, all operations that are located between these two comment lines will be selected.

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

    The Make Data Loop Command

    Click the image to enlarge it.

    The Data-Driven Loop wizard will appear.

  3. On the first page of the wizard, you can specify either a new DB Table variable that will get records of the needed data storage or an existing one. To create a new variable, choose the Create new variable option button and specify the variable’s name.

    Click Next to continue.

  4. On the next page of the wizard, you select the type of the data source, from which the created variable will retrieve data:

    Select Excel worksheet and click Next to continue.

  5. On the next page, you specify an Excel file:

    • Click the ellipsis button of the File Name box. This will invoke the standard Open File dialog.

    • In the dialog, select the Excel file that stores the test data. In one of the previous steps, we said that we would use the TestBook.xlsx file. You can find it in the <Users>\Public\Public Documents\TestComplete 15 Samples\Common\Data-Driven Testing\ folder.

      Note: Some file managers can display the Public Documents folder as Documents.
    • Click Next.

  6. On the next page, you select the sheet that contains the test data. Our sample Excel file contains only one sheet.

    Select it and click Next to continue.

  7. On the next page, you specify the range of data rows to be used for testing.

    Leave the default values and click Next to continue.

  8. The next page lists the parameters the selected operations use. On this page, you update parameter values with data retrieved from the data source.

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

    Click in the Value cell of the needed parameter and select the needed column of the data source from the drop-down list.

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

    Note: You may want to set the data type of a value explicitly. In this case, see the Retrieving Input Data From Storage topic.

    Specify the following columns for the parameters:

    Control Recorded Value Test Parameter
    Customer "John Smith Jr" Name [Column]
    Product "FamilyAlbum" Product [Column]
    Quantity "20" Quantity [Column]
    Date "5/6/2005" Date [Column]
    Street "12, Orange Blvd" Street [Column]
    City "Grovetown, CA" City [Column]
    State "US" State [Column]
    ZIP "111155" Zip [Column]
    Card No "555777555888" Credit Card No [Column]
    Expiration Date "06.05.2005" Expiration Date [Column]
    Property checkpoints "$80"
    "15%"
    "$1360"
    Price [Column]
    Discount [Column]
    Total [Column]

    Important: Remember to update the parameters used by property checkpoints so that they also become data-driven.

    Updating property checkpoints
  9. Click Finish to complete the data-driven loop creation.

After you click Finish, TestComplete will add the Data-Driven Loop operation to the recorded test and move the selected operations as its child operations. Also, it will update the parameters of the moved operations with the values specified in the Data-Driven Loop wizard.

The Modified Test

Click the image to enlarge it.

As you can see, when adding the Data-Driven Loop operation, we modified parameters of all the operations to be executed in a loop, except for the operation that enables the MasterCard option button. In the next step, we will modify this operation so that it can enable the other Card option buttons.

Prev     Next

See Also

Tutorial Home Page
About Keyword Test Editor

Highlight search results