If...Else

You can also review our Telerik TV episode on the If...Else 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 2.
  4. Click Generate.
  5.  

     

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

     

  8. Click Quick Tasks and double click Verify - text contains '1'.
  9.  

     

  10. Disable hover over highlighting and minimize the browser.
  11. Click the Logical button in the Add ribbon. Choose if...else.
  12.  

    Standalone version

    VS plugin

     

  13. Hover over the IF step and click the green plus icon.
  14.  

     

  15. Click the green plus icon that appears next to the Verify step to associate it with the IF statement.
  16.  

     

  17. Bring up the IE recording window and navigate to www.google.com. Minimize the browser again.
  18. Drag the Navigate to Google step into the IF step.
  19.  

     

  20. Bring up the IE recording window and navigate to www.bing.com. Minimize the browser again.
  21. Drag the Navigate to Bing step into the ELSE step.
  22.  

     

  23. Save and Execute the test.
    • If 1 is generated it navigates to Google.
    • If 2 is generated it navigates to Bing.

Results

  • Test steps in an if branch are skipped when an If condition was evaluated as false (for example, the target TextBox element contains the wrong content). Likewise, steps in an else branch are skipped when the if condition is evaluated as true. Steps skipped for this reason show a warning icon.



  • However, if the condition of an if branch cannot be evaluated (for example, the target element for a TextContent verification cannot be located), the steps in the if branch will be skipped, and will display a 'not-run' icon.

    Not-Run Icons