
In some scenarios, it is impossible to predict the number of times a loop should be executed. For example:
A user repeatedly queries a Check Status page until the server completes a slow, asynchronous transaction and redirects to a Result page. When recording such a test case, it is unknown how many times each virtual user should request the Check Status page during the load test.
To handle such cases, a Do...While (Conditional Loop) is used. This loop evaluates an exit condition at the end of each iteration to determine whether to continue or stop. You can configure the loop to exit when the condition evaluates to either true or false.
Creating a Do...While Loop
Follow these steps to create a Do...While loop:
- Navigate to the Build Test Case node.
- Select the starting object for the loop.
- Right-click to open the context menu and choose Create Container → Create Do...While.
- A new object dialog appears.
- Select the last object in the loop.
- Click Create Do...While to complete the loop configuration.
| |
| This process ensures the loop continues executing until the defined exit condition is met. |
|
|
|
Quick Creation of a Do...While Loop
Another way to create a Do...While loop is by using the quick creation method:
- Select multiple objects in the Test Case Tree.
- Right-click to open the context menu.
- Click Create Do...While.
This will automatically generate a Do...While loop around the selected objects.

Exit Condition Types
A Do...While loop can be configured to exit based on one of the following conditions:
- Compare Expressions – Evaluates a condition by comparing values (e.g., response code, extracted variables).
- Search Response – Checks whether a specific string or pattern exists in the response.
Compare ExpressionsThe Compare Expressions exit condition type allows the loop to continue or exit based on the comparison of two expressions using a specified operand. An expression can consist of text, variables, or a combination of both. Configuring a Compare Expressions Condition- In the Condition Type (a) property, select Compare Expressions.
- Enter values or variables in the following fields:
- Left Expression (b) – The first expression to compare.
- Right Expression (d) – The second expression to compare.
- To insert a variable, click the down arrow in the property grid to open the variable picker.
- Define the operand for comparison (e.g., equals, greater than, less than).
In the Compare Operator (c) property, select an operator to compare the Left Expression and Right Expression. The available operators are: - = – Returns
true if both expressions return the same value. - > – Returns
true if the left expression returns a value greater than the right expression. - >= – Returns
true if the left expression returns a value greater than or equal to the right expression. - < – Returns
true if the left expression returns a value less than the right expression. - <= – Returns
true if the left expression returns a value less than or equal to the right expression. - Contains – Returns
true if the left expression contains the value returned by the right expression. - Starts with – Returns
true if the left expression starts with the right expression. - Ends with – Returns
true if the left expression ends with the right expression. - Exists – Returns
true if the left expression is not empty (i.e., its length is greater than 0). This is useful for checking if an extractor value exists.
The Exit loop if compare condition is true? (e) property determines when the loop should exit based on the result of the expression comparison. - Yes – The loop exits when the comparison evaluates to true. It continues executing as long as the condition evaluates to false.
- No – The loop exits when the comparison evaluates to false. It continues executing as long as the condition evaluates to true.
The loop will evaluate the condition at the end of each iteration and continue executing until the condition is met. | |
Search responseThe Search Response exit condition checks for the presence of a specified text or regular expression in an HTTP response. The loop continues or exits based on whether the search criteria are met. Configuring a Search Response ConditionSelect the condition type: - In the Condition Type property, select Search Response (10).
Choose the response to analyze: - In the Response to Search (a) property, select the ID of the HTTP response to examine.
Define the search expression: - In the Search Expression (b) property, specify the text or regular expression to search for in the HTTP response.
Set the search type: - In the Search Type (c) property, select:
- Text – If the search expression is plain text.
- RegEx – If the search expression is a regular expression.
Determine exit behavior: - In the Exit Loop if Match Found? (d) property, select:
- Yes – The loop exits when the search text is found in the response. It continues if the text is not found.
- No – The loop exits when the search text is not found in the response. It continues if the text is found.
This configuration allows you to dynamically control loop execution based on real-time response content.
| |
Other propertiesThe Do...While loop includes additional configuration options to control loop execution behavior. 1. Number of Repeats (Max) (a)- A positive integer that defines the maximum number of loop repetitions.
- The loop cannot exceed this value. Ensure this value is higher than the expected maximum number of repeats.
2. Delay Before Next Loop (b)- A non-negative decimal number specifying the delay (in seconds) between loop iterations.
- The delay is applied after the previous iteration and before the next one starts.
3. When to Apply Delay (c)- Determines whether the delay should occur at the start or end of each iteration. Options:
- Beginning of the loop – Delay before each loop iteration.
- End of the loop (default) – Delay after each loop iteration.
4. Include Delays in Parent Transaction Time (d)- Specifies whether delays should be included in the parent transaction time.
- Yes – Delays are added to the transaction time.
- No (default) – Delays are excluded from the transaction time.
5. Action on Loop Completion After Max Repeats (e)- Defines what happens if the loop reaches the maximum repeat count without meeting the exit condition. Possible actions:
- Continue – Proceed to the next step in the test case.
- Abort iteration – Stop the current iteration and start a new one.
- Abort VU – Stop sending requests from this Virtual User (VU).
- Go to the last transaction – Skip to the last top-level transaction (usually logout) and start a new iteration.
6. Increment Index for Iteration-Bound Datasets? (f)- Defines whether the dataset index should be incremented with each loop iteration.
- Yes – The dataset index increments for each iteration.
- No (default) – The dataset index remains the same for each iteration.
- This is useful for data-driven tests. For more details, see Databinding .
| |