Adding a loop to a test

You can define part of a test as a loop that runs a specified number of times. If the loop contains a synchronization point, the synchronization point is released after the first iteration of the loop and stays released for all further iterations.

About this task

You can set a loop within a schedule or a test. The following table shows the advantages of both methods:
Loop location Results


Loops in schedules are easy to locate and modify.Loops in schedules close the server connection at the end of each iteration and reopen it at the beginning of the next iteration. This action models the behavior of a user closing and reopening a browser. Use this method to run a test at a set rate.

Test Loops in tests can be more granular, and thus provide a higher level of control.

Loops in tests reuse the server connection during each loop iteration.

Use this method, with loops that have high iteration counts, to stress test a server.


  1. In the Test Navigator, browse to the test, and double-click it.
    The test opens.
  2. Click the page or the request that will be inside the loop.
    Press Ctrl when clicking to select multiple pages or requests.
  3. Click Insert, and select Loop.
  4. You are asked whether you want to move the selected elements into a the loop. Click Yes.
    If you click No, an empty loop is inserted into the test.
  5. In the Loop Details area, type the number of iterations for the loop to repeat.
    Count-based Runs for the number of iterations that you select.
    Time-based Runs for at least the time that you specify. The loop always finishes the iteration. For example, if you select a time of 1 second and a loop takes 10 seconds to run, the loop finishes one iteration, and then checks the time.
    Infinite Runs until the test stops.

    If a test or a schedule includes multiple loops with dataset values and a new dataset value is required for the first iteration of the second loop, then a dataset increment is required before the second loop runs. To do this, you must insert a data source controller by clicking Insert > Data Source Controller before the second loop starts and then select the required dataset. You can then select the Increment option for the data source from the Data Source Controller Details pane that triggers the retrieval of the dataset value to automatically choose the new dataset value.

  6. Optional: Select Control the rate of iterations, and type your preferences for the pacing rate.
    In specifying a number of iterations for a unit of time, you set a fixed period for the iterations to complete. If you select Randomly vary the delay between iterations, the total delay is randomly distributed. If you clear this check box, the same delay occurs between each iteration.
    Note: Statistically, the Randomly vary the delay between iterations option sets delay amounts at random from a negative exponential distribution with the same mean as the fixed delay value. The negative exponential distribution has a long "tail," which means that a very small number of delays will have very large values. Therefore, make sure that the application you are testing is not negatively affected by long periods of inactivity (such as a timeout that disconnects the user).