New to Telerik Test Studio? Download free 30-day trial

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.

Random

5.  Enable hover over highlighting and hover over the Result box.

6.  Click Build Step.

Build Verification

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.

Content

8.  Disable hover over highlighting and minimize the browser.

9.  Choose Conditions in the Step Builder and add while...loop step.

Standalone
Standalone version
VS Plugin
VS Plugin

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

Choose Verification

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

Uncheck Verification

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

Drag into 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.

Drag Execution 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.

While condition is evaluated at least once as true

An execution status example when the while condition is false and the steps in the while loop are not run at all.

While condition is evaluated at least once as false

In this article