While...Loop
Walk--through of Do...While Statement process and execution status overview.
Build a While loop
1. Create a Web Test and click Record.
2. Navigate to www.random.org.
3. Set the Min field to 1 and the Max field to 10.
4. Click Generate.
5. Enable hover over highlighting and hover over the Result box.
6. Click Build Step.
7. Choose Content under Verifications in the Step Builder.
- Set the first drop-down to InnerText.
- Set the second drop-down to NotContain.
- Click Add Step.
8. Disable hover over highlighting and minimize the browser.
9. Choose Conditions in the Step Builder and add while...loop step.
10. Choose the verification we've already added from the dropdown of the While step.
11. Uncheck/Delete the verification step so it will not be executed (We have this verification already added in the while step)
12. Drag the Click Generate Button step into the WHILE step.
13. Add an Execution Delay step from the More drop-down in the Add ribbon. Set it to 20 milliseconds.
14. Drag the Execution Delay step into the WHILE step.
Execution Status
15. Click Save and Execute. The test will continue to generate a random number between 1 and 10 until it generates the number referenced in the Verify step (4 in this example).
The While step will be always marked as 'Passed' since it is always executed - the condition is to be evaluated. Depending on whether the condition evaluation is true or false the test will either execute the *while branch * steps or skip and show them as 'Not Run'.
An execution status example when the while loop is executed few times and the steps in the while loop are executed at least once.
An execution status example when the while condition is false and the steps in the while loop are not run at all.