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
- Double-click a test in the Test Navigator pane. The test opens.
-
Select the steps to be added to the
If
block, right-click and then click Split Mobile or Web UI actions. - Select Split and create container, and then select If from the drop-down list.
-
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. -
Click the
If
block and then click to add theElse
block.TheElse
block is created and the steps from theIf
block moves toThen
node. -
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.
-
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.
- Save the test.