Conditional statements enable you to control the flow of your Test or component. You use the IF … THEN and ELSE statement to incorporate decision-making in your tests. The IF … THEN statement evaluates whether a condition is true. If the condition is true, the statements following IF … THEN are executed. If condition is not true, the statements
following the ELSE are executed.

The syntax to add an IF … THEN and ELSE statement to your test is:

If [condition] Then
[statement]
Else
[else statement]
End If

Adding a CONDITIONAL STATEMENT: To add an IF … THEN step in KEYWORD VIEW:

  1. In KEYWORD VIEW, select the step where you want to add the conditional statement.
  2. From the QuickTest Professional menu bar, select INSERT ? CONDITIONAL STATEMENT ? IF … THEN. The STATEMENT step is added in KEYWORD VIEW.
  3. Click the STATEMENT step. The step changes to a list.
  4. From the STATEMENT list, select the type of step that you want to add.
  5. Select an object from Object Repository and ensure that the operation is correct.
    (For example, EXIST, ACTIVATE, or CLICK).
  6. In the VALUE column, type a value that you want to set for the IF statement.

Selecting Statement Type: To add a conditional step to a test in KEYWORD VIEW:

  1. From the QuickTest Professional menu bar, select INSERT ? CONDITIONAL STATEMENT ? IF … THEN. The STATEMENT step is added to KEYWORD VIEW.
  2. Click the STATEMENT in the IF step. The step changes to a list.
  3. Select one of the following statement types from the list:
    – OBJECT FROM REPOSITORY
    Step Generator

Related posts:

  1. Adding the Else Statement in QTP
  2. Splitting an Action in QTP
  3. Defining a New Test Object
  4. Adding a Comment
  5. Working With Step Generator in QTP