You can insert conditional statements to verify the values of the variables in the
script and perform actions in the application.
All variables to be tested while running conditional statements must be captured during
the script recording. To do this, you must use the Get a Specific Property Value feature that
is available in the verification point wizard while recording the script to assign a control
property to a variable in the script.
-
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.
-
Select the variable that must be verified in the Left Side
field.
The Left Side field lists all the variables that are
declared during the script recording before the selected test line.
-
Select the required parameter in the Compares To
field.
-
Type the variable value in the Right Side field.
For string values, you must specify the value using quotation marks, for example,
"Visa". You can also select another variable from the list if
the first operand must be verified against another variable.
- 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 or Then clause, or
any test lines in the Then 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.
In this example, a conditional statement if (Item_text EQUALS
"Schubert") has been inserted into the functional test script. The test lines
grouped under the Then group are run only when the value of the variable
Item_text is Schubert. This script, when run on the ClassicsJavaA
application, will place the order only if the value of the variable Item_text is
Schubert. 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