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

  1. In the Test Navigator, browse to the test and double-click it. The test opens.
  2. Select the steps to be added to the IF block, right-click and click Split Mobile or Web UI actions.
  3. Click Split and create container, select If from the drop down list, and click Finish.
    Split Mobile or Web UI actions
    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.
    Test script with If block
  4. To add the Else block, click the If block and click Add > Condition (If) - ELSE Block.
    The Else block is created and the steps from the If block moves to Then node.
    Test script with If-Else block
  5. 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.
  6. In the Test Element Details area, under Options, choose the required comparison type by selecting or clearing the check boxes and save the changes.