You can also review our Telerik TV episode on the If...Else Statement for a video walk-through of this process.
- Create a Web Test and click Record.
- Navigate to www.random.org.
- Set the Min field to 1 and the Max field to 2.
- Click Generate.
- Enable hover over highlighting and hover over the Result box. Click the blue nub.
- Click Quick Tasks and double click Verify - text contains '1'.
- Disable hover over highlighting and minimize the browser.
- Click the Logical button in the Add ribbon. Choose if...else.
- Hover over the IF step and click the white star.
- Click the white star icon that appears next to the Verify step to associate it with the IF statement.
- Bring up the IE recording window and navigate to www.google.com. Minimize the browser again.
- Drag the Navigate to Google step into the IF step.
- Bring up the IE recording window and navigate to www.bing.com. Minimize the browser again.
- Drag the Navigate to Bing step into the ELSE step.
- Save and Execute the test.
- If 1 is generated it navigates to Google.
- If 2 is generated it navigates to Bing.
- 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 'not-run' 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.