Adding conditional logic

You can insert if/else constructs around parts of a test that make execution of those parts dependent on whether a specified condition is met.

In most cases, a conditional block issues HTTP requests depending on the value of a reference or field reference. These must exist in the test and appear sequentially prior to the conditional block. If the reference or field reference that the conditional block will use for input does not exist, create it as explained in Creating a reference or field reference.

The test may contain the request(s) to be issued whenever the reference check resolves to true. If this is the case, select the request(s) in the second step of the procedure and use the Insert action button. To create an empty conditional block at the end of the selected object (test or request), click the object and then the Add button. The following instructions explain the former: adding conditional blocks that contain requests from the test.

To add a conditional block:
  1. Open the test.
  2. Click a page or page request. The block is inserted before the selected item and step 5 optionally copies the item(s) to the block.
  3. Use Shift-click and Ctrl-click to multi-select pages or requests to be copied into the block. In step 6, if you choose to add an Else block, you can select one or more of these items to be copied into the Else branch.
  4. Click Insert and select 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, as illustrated in the figure, the element(s) you selected are copied under If in the Test Contents and into the Then box in the Test Element Details.
  6. If you want an Else block:
    1. In the Test Contents, under If, select the elements(s) that should be copied to the Else block. Use Shift-click or Ctrl-click to select multiple items.
    2. Right-click and select Insert > 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, as illustrated in the figure, the element(s) you selected are copied under Else in the Test Contents and into the Else box in the Test Element Details.
  7. In the Test Element Details, under Condition:
    1. In the First operand box, either select the input for the block (a reference containing a string value to be compared with the Second operand, or a field reference to be used with the contains operator.) or type a value.
    2. In the Operator box, indicate the basis of comparison of the two operands. Note that the two operands are strings.
    3. In the Second operand box, either select the input for the block (a reference containing a string value to be compared with the First operand) or type a value. With the default operands (true) and operator (Equals), the block is always executed.
  8. In the Test Element Details, under Options, choose the desired comparison type by checking or clearing the check boxes.

Parent topic: Adding elements to a test

Terms of use | Feedback
(C) Copyright IBM Corporation 2005. All Rights Reserved.