Inserting conditional statements
You can insert conditional statements to verify the values of the variables in the script and perform actions in the application.
Before you begin
Procedure
- Select the test line in the script editor.
-
Right-click and select Insert Condition (If Clause) ().
An If Then clause is inserted in the script editor. The selected test line is inserted in the Then group.
- Select the If clause.
-
In the Properties-General view, specify the variable values that
must be verified.
- Optional: To run other test lines that must also run if the variable conditions are met, select and drag the test lines into the Then group.
-
You can insert the Else clause for the test lines that must be run if the variable
conditions are not met. Select the
If
orThen
clause, or any test lines in theThen
group, right-click and select Insert Else Clause ().Select and drag the test lines that must be executed if the variable conditions are not met into the Else group. -
Click
to save the script.During script playback, the variable conditions are checked and the required test lines are run.
Example
Start Application ClassicsJavaA
ClassicsCD
Click tree2 at Composers->Schubert->Location(PLUS_MINUS)
Click tree2 at Composers->Schubert->String Quartets Nos. 4 & 14
Click Place Order
Member Logon
Click OK
Place an Order
Get Property Item: text
if (Item_text EQUALS "Schubert")
Then
Click Card Number (include the spaces)
Type Value 12345678
Click Expiration Date
Type Value 12/12
Click Place Order
Message
Click OK
ClassicsCD
Close ClassicsCD