Thursday, March 15, 2007

Verifying Text

In this exercise you add an if/else statement to the test script in order to determine
whether the total was updated in the graph after you placed an order.
1 In the first obj_get_text statement in the lesson9 test script, change the
text variable to first_total.
2 In the second obj_get_text statement in the test script, change the text
variable to new_total.
3 Place the cursor below the last line of the script.
4 Add the following statements to the test script exactly as they appear
below.
if (new_total == first_total + 1)
tl_step ("graph total", 0, "Total is correct.");
else
tl_step ("graph total", 1, "Total is incorrect.");
In plain English, these statements mean "If new_total equals first_total plus 1,
report that the total is correct, otherwise (else) report that the total is incorrect."
5 Add a comment to describe what this section of the script will do.
Place the cursor above the if statement you added in the previous step. Choose
Edit > Comment. After the # sign, type: check that graph total increments by
one.
6 Save the test.
Choose File > Save or click the Save button.

Debugging the Test Script
You should now run the test in Debug mode in order to check for errors in syntax
and logic. If any error messages appear, look over the test script and try to fix the
problem.
1 Select Debug mode from the Run Mode list on the Standard toolbar.
Debug mode will stay in effect until you select a different mode.
2 Run the test.
Choose Run > Run from Top or click the Run from Top button. If you prefer to
run the test line by line, use the Step button.
3 Review the test results in the WinRunner Test Results window.
Choose Tools > Test Results or click the Test Results button. The WinRunner
Test Results window displays the results of the Debug test run.
If the tl_step event failed, a problem exists in the test script. Examine the script
and try to fix the problem.
4 Close the Test Results window.
Choose File > Exit in the WinRunner Test Results window.
5 Exit the Flight Reservation application.
Choose File > Exit.