Add conditional logic

 

+

Search Tips   |   Advanced Search

 

Overview

You can insert IF-THEN logic around portions of a test to make those portions run if a specific condition is met.

A conditional block can run portions of a test depending on the value of a reference or field reference. The reference or field reference must exist in the test and precede the conditional block.

If the reference or field reference that the conditional block will use for input does not exist, create it.

The test might already contain the test elements that are to be run.


Add a conditional block

  1. Double-click a test

  2. Click a page or page request.

    The conditional block is inserted before the selected item, and step 5 optionally moves the item to the block.

  3. Press Shift or Ctrl when clicking to select multiple pages or requests to be moved into the block.

    In step 6, if you add an Else block, you can select one or more of these items to be moved into the Else branch.

  4. Right-click the item and select...

      Insert | Condition (IF)

    You are prompted: Would you like to move selected objects into the new IF?

  5. Click Yes or No.

    The If block is inserted into the test. If you click Yes the items you selected are moved under If in the Test Contents area. The following example shows an If block with an HTTP test.

  6. To add an Else block:

    1. In the Test Contents area, under If, select the items to be moved to the Else block.

      Press Shift or Ctrl when clicking to select multiple items.

    2. Right-click and select...

        Insert > Condition (IF) - ELSE Block

      You are prompted: Would you like to move selected objects into the new ELSE?

    3. Click Yes or No.

      The Else block is inserted into the test. If you click Yes the items you selected are moved under Else in the Test Contents area and into the Else field in the Test Element Details area. The following example shows an If-Then-Else block with an HTTP test.

  7. In the Test Element Details area, under Condition:

    1. Next to the First operand field, click Data Source and then select a data source to be compared with the Second operand, or type a value in the First operand field.

    2. In the Operator field, indicate the basis of comparison of the two operands. Note that the two operands are strings.

    3. 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.

  8. In the Test Element Details area, under Options, choose the desired comparison type by selecting or clearing the check boxes.


Related tasks

  1. Add a comment
  2. Add a transaction to a test
  3. Synchronize users in tests
  4. Add a loop to a test