Lesson 9: Adding a loop

You can learn about adding a loop to a test so that the test runs repeatedly for a specified number of time, while fetching values from an associated dataset. You can either select a count-based, a time-based, or an infinite loop for the test. You can set the loop to infinite if you want the test to fetch the data from all the rows in a dataset.

Before you begin

You must have completed the following tasks:

About this task

For the test scenario in this tutorial, you can use AnimalsDataset as the associated dataset that has three entries. You can add a loop with three iterations to the test.

Procedure

  1. Select the wiki-search-animals test in the Compound Test Contents panel, and then click Insert > Loop.
    Image of the Compound Test Contents panel

    The New Loop dialog is displayed.

  2. Click Yes to move the wiki-search-animals test to a new loop.
    The wiki-search-animals test is displayed within a loop in the Compound Test Contents panel.
  3. Enter wiki-loop as the loop name in the Loop Details panel.
  4. Select the Count-based option, and then enter 3 in the iterations field.
    Image of the Loop details panel

  5. Click File > Save to save the changes.
  6. Click Run Compound Test to run the test.
    The Confirm Perspective Switch dialog is displayed.
  7. Click Switch to run the test in the Test Execution perspective.
  8. Select Chrome in the Run Configuration dialog.
  9. Click Finish.
    The compound test run begins. The wiki-search-animals test runs three times while fetching the data from the AnimalsDataset dataset.

Results

You have learned to add a loop to a test so that the test runs repeatedly for a specified number of time.

What to do next

You can verify whether the recorded actions are successfully displayed in the test log and test reports after the test run is completed. You can verify the following:
  • The associated dataset is successfully applied for the search action during the playback.
  • The animal name in the test is substituted with the animal names that are listed in the dataset.
  • The test is successfully repeated for the specified number of iterations.