While...Loop

You can also review our Telerik TV episode on the Do...While Statement for a video walk-through of this process.

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.

Random

5.  Enable hover over highlighting and hover over the Result box. Click the blue nub.

6.  Click Build Verification.

Build Verification

7.  Click the Content button under Available Verifications.

  • Set the first drop-down to InnerText.
  • Set the second drop-down to NotContain.
  • Click OK.

Content

8.  Test Studio recognizes you are verifying the number is not 5, when indeed it is 5. Click Yes to continue.

Click Yes

9.  Disable hover over highlighting and minimize the browser.

10.  Click the Logical button in the Add ribbon. Choose while...loop.

Standalone
Standalone version
VS Plugin
VS Plugin

11.  Choose the verification we've already added from the dropdown of the While step.

Choose Verification

12.  Uncheck/Delete the verification step so it will not be executed (We have this verification already added in the while step)

Uncheck Verification

13.  Drag the Click Generate Button step into the WHILE step.

Drag into While Step

14.  Add an Execution Delay step from the More drop-down in the Add ribbon. Set it to 20 milliseconds.

15.  Drag the Execution Delay step into the WHILE step.

Drag Execution Step

16.  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).