You can insert IF-THEN logic
around portions of a test to make those portions run if a specific
condition is met.
Before you begin
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 as explained in Creating a reference
or field reference.
The test might already contain the
test elements that are to be run.
- If this is the case, select the requests in step 2 of the procedure
and click Insert. The following instructions
explain how to add a conditional block that contains such requests.
- Otherwise, you can create an empty conditional block at the end
of the selected item (test or request). Click the object and then
click Add.
About this task
To add a conditional block:
Procedure
- In the Test Navigator, browse to the test and double-click
it. The test opens.
- 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.
- 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.
- Right-click the item and select . You
are prompted: Would you like to move selected objects into
the new IF?
- Click Yes or No. The If block is inserted into the
test. If you click Yes, as shown in the example,
the items you selected are moved under If in
the Test Contents area. The following example
shows an If block with an HTTP test.
- To add an Else block:
- 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.
- Right-click and select . You are prompted: Would you like to move selected
objects into the new ELSE?
- Click Yes or No. The Else block is inserted into
the test. If you click Yes, as shown in the
example, 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.
- In the Test Element Details area, under Condition:
- 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.
- 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.
- In the Test Element Details area, under Options,
choose the desired comparison type by selecting or clearing the check
boxes.