Adding conditional logic to tests

You can insert the If-Else logic for a section of test to make those steps run only if a specific condition is met.

Procedure

  1. Double-click a test in the Test Navigator pane. The test opens.
  2. Select the steps to be added to the If block, right-click and then click Split Mobile or Web UI actions.
  3. Select Split and create container, and then select If from the drop-down list.
  4. 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
  5. Click the If block and then click Add > Condition (If) - ELSE Block to add the Else block.
    The Else block is created and the steps from the If block moves to Then node.Test script with If-Else block
  6. Add the following conditions in the Conditional (IF) Block Details area, under:
    • 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.
  7. Under Options, choose any of the comparison types by selecting the checkbox:
    Option Description
    Negate the operator (NOT(op)) Negates a condition when you perform a comparison.

    You can use the Negate the operator option to obtain an opposite result of any test condition. For example, if the result of any condition is true, the result returns to false, and if the result of any condition is false, the result returns to true.

    Case-sensitive comparison Performs a case-sensitive string comparison.

    You can use Equals in the Operator to perform a case-sensitive comparison in a test.

    Compare as integers

    Performs a digit comparison when the two operands are integers to return the result, true or false.

  8. Save the test.