Adding conditional logic to tests
You can insert IF-ELSE logic around portions of a test to make those portions run if a specific condition is met.
Procedure
- In the Test Navigator, browse to the test and double-click it. The test opens.
- Select the steps to be added to the IF block, right-click and click Split Mobile or Web UI actions.
- Click Split and create container,
select If from the drop down list, and click Finish.The selected steps along with the Launch Application node are moved to the If block and the rest of the steps are added to the In Application node.
- To add the Else block, click the If block and click .The Else block is created and the steps from the If block moves to Then node.
- In the Test Element Details area, under Condition add conditions:
- Next to the First operand field, click Data Source, and then select a data source to be compared with the string in the Second operand field, or type a value in the First operand field.
- In the Operator field, indicate the basis of comparison of the two operands. Note that the two operands are strings.
- Next to the Second operand field, click Data Source, and select a data source to be compared with the First operand, or type a value in the Second operand field. When the defaults are used (both operand fields set to true and the Operator field set to Equals), the block is always processed.
- In the Test Element Details area, under Options, choose the required comparison type by selecting or clearing the check boxes and save the changes.