QTP 90 Exercises
QTP 90 Exercises
0
Exercises
Exercise: Preparing the Test Environment
Use the Windows-based Flight Reservation application to prepare for recording.
Before creating a test, set up the test environment and get familiar with the
application under test. Use the best practices to prepare for and implement your
automated test. This exercise is divided into following parts.
3. Click OK.
2. IN THE GENERAL tab, click RESTORE LAYOUT to ensure that the layout is
uniform and all panes and toolbars are displayed in their default
positions and sizes.
5. Ensure that the VIEW RESULTS WHEN RUN SESSION ENDS check box is
unchecked.
6. Ensure that the ALLOW OTHER MERCURY PRODUCTS TO RUN TESTS AND
COMPONENTS check box is unchecked.
8. Click OK.
PASSWORD: mercury
4. From the QuickTest Professional menu bar, select FILE > NEW >
TEST.
6. Start and end recording from the FLIGHT RESERVATION window to set
the window as the initial and end condition for the test.
Notice that the QUICKTEST PROFESSIONAL window has resized for recording.
You can move and resize the QUICKTEST PROFESSIONAL window. This
movement does not impact the recording. Position the QUICKTEST
PROFESSIONAL window and the FLIGHT RESERVATION window so that you can
see both.
2. On the FLIGHT RESERVATION toolbar, click the NEW ORDER icon to set
the initial condition. Notice that a step is added in the KEYWORD VIEW.
DATE: 11-11-09
TICKETS: 2
CLASS: FIRST
7. Click INSERT ORDER. Wait for the progress bar to complete. When the
insertion is complete, the INSERT DONE... message appears.
8. On the FLIGHT RESERVATION toolbar, click the NEW ORDER icon to set
the end condition.
4. Click SAVE.
For training purposes, a directory tree was set up on one of your local drives
under \QTP90USING\TESTS. Save all your tests in this directory.
2. From the tree on the left side of TEST RESULTS window, right-click the
TEST <TEST> SUMMARY node and select EXPAND ALL.
2. In the QuickTest Professional menu bar, select FILE > NEW > TEST.
3. Click RECORD. The RECORD AND RUN SETTINGS dialog box appears.
NAME: Maura
TICKETS: 2
CLASS: First
Answer: Seven
FLIGHT RESERVATION, FIRST, DATE OF FLIGHT, (TICKETS and NAME), (FLY TO
and FLY FROM), (INSERT ORDER, FLIGHT, and BUTTON), and FLIGHTS TABLE.
After you are done, close the OBJECT REPOSITORY dialog box.
Part 3: Change the Logical Name of an Object
1. From the QuickTest Professional menu bar, select RESOURCES >
OBJECT REPOSITORY. The OBJECT REPOSITORY dialog box appears.
5. Press ENTER.
3. In the OBJECT SPY dialog box, click the pointing finger button. The
mouse cursor changes to a pointing finger.
4. In the FLIGHT RESERVATION window, click the NAME field with the
pointed finger cursor. The OBJECT SPY dialog box shows the object
properties for the NAME field.
ENABLED ______________________
NATIVECLASS ______________________
The answers in order are:
Answer: A temporary frame blinks around the NEW ORDER icon in the
FLIGHT RESERVATION window.
2. On the Object Repository toolbar, click the DEFINE NEW TEST OBJECT
button. The DEFINE NEW TEST OBJECT dialog box appears.
6. In the TEST OBJECT DETAILS section, click the VALUE column for the
TEXT property, and type OK.
7. Click ADD to add the new test object to the local object repository.
8. Click CLOSE to close the DEFINE NEW TEST OBJECT dialog box. A new
object is added under the FLIGHT object.
2. From the QuickTest Professional menu bar, select FILE > NEW > TEST
to open a new test.
4. In the TEST SETTINGS dialog box that appears, click the RUN tab.
6. Click OK.
9. On the Flight Reservation toolbar, click the NEW ORDER icon to set
initial conditions for the test.
NAME: MAURA
TICKETS: 2
Class: FIRST
16. On the Flight Reservation toolbar, click NEW ORDER to set end
conditions.
2. In the RUN dialog box, ensure that the TEMPORARY RUN RESULTS FOLDER
option is selected.
3. Click OK. The test should fail. A RUN ERROR message box appears.
4. Notice the type of error message and close the RUN ERROR message box.
Error is: OBJECT IS DISABLED
4. To insert a synchronization point on the progress bar, from the menu bar,
select INSERT> SYNCHRONIZATION POINT. The cursor changes to a
pointed finger.
5. In the progress bar, click the words INSERT DONE... with the pointed
finger cursor. The OBJECT SELECTION - SYNCHRONIZATION POINT dialog
box appears.
13. On the QuickTest Professional toolbar, click RUN to run the test. The
RUN dialog box appears.
14. Click OK to close the RUN dialog box. The test should succeed.
15. On the QuickTest Professional toolbar, click the RESULTS icon to view
the test results. The TEST RESULTS window appears.
16. View the test results and close the TEST RESULTS window.
7. Click the FLIGHTS button. The FLIGHTS TABLE dialog box appears.
8. In the FLIGHTS TABLE dialog box, click OK to accept the default choice.
9. Enter the following information:
TICKETS: 2
CLASS: FIRST
10. Click the Insert Order button. Wait for the progress bar to complete and
for the words INSERT DONE... to appear.
12. In the FLIGHT RESERVATION window, in the progress bar, click the
words INSERT DONE... with the pointing hand cursor. The OBJECT
SELECTION - CHECKPOINT PROPERTIES dialog box appears.
14. In the CHECKPOINT PROPERTIES dialog box, check the TEXT property and
uncheck all other properties.
16. IN THE FLIGHT RESERVATION toolbar, click the NEW ORDER button to
set end condition for the test.
17. On the QuickTest Professional toolbar, click STOP to stop the test.
2. In the RUN dialog box, click OK. The TEST RESULTS window appears.
3. In the TEST RESULTS window, expand the TEST SUMMARY tree. Ensure
that a checkpoint is used to verify that the INSERT DONE step is
successful. The TEST RESULTS SUMMARY displays the STATUS as
PASSED with a value of 1.
2. In ACTIVE SCREEN, the ORDER NO: field must show the number
generated after the insert done operation.
3. In ACTIVE SCREEN, right-click the ORDER NO: field (not on static text)
and select INSERT STANDARD CHECKPOINT. The OBJECT SELECTION -
CHECKPOINT PROPERTIES dialog box appears.
6. Ensure that when you select the TEXT property, the ORDER NO appears
in the CONSTANT field.
7. Click OK.
9. On the QuickTest Professional toolbar, click RUN to run the test. The
test should fail.
10. View the test results. The test failed. In the next lab, you will correct
for the failure.
9. On the QuickTest Professional toolbar, click RUN to run the test. The
test should pass.
2. Click RECORD. The RECORD AND RUN SETTINGS dialog box appears.
5. From the FLIGHT RESERVATION menu bar, select FILE > OPEN ORDER.
The OPEN ORDER window appears.
6. In the OPEN ORDER window, check the ORDER NO. check box.
8. CLICK OK.
9. FROM THE FLIGHT RESERVATION menu bar, select FILE > FAX ORDER.
10. INSERT A STANDARD checkpoint for the SEND SIGNATURE WITH ORDER
check box.
11. In the CHECKPOINT PROPERTIES dialog box, ensure that the CHECKED
check box is checked and has OFF as the value.
14. IN THE FLIGHT RESERVATION window, click the NEW ORDER button to
set end conditions.
3. On the QUICKTEST toolbar, click the RESULTS button to check the test
results. The TEST RESULTS window appears. The test should pass.
5. View the test results. The test failed. In the next lab you will correct the
problem.
2. In the OBJECT REPOSITORY tree, select the FAX ORDER NO. 3 object.
3. In the OBJECT PROPERTIES pane, in the VALUE column, click to display
the CONFIGURE THE VALUE button.
9. Click OK.
2. Ensure that Flight Reservation application is running and you are logged
on.
3. From the QuickTest Professional menu bar, select FILE > NEW >
TEST.
TICKETS: 2
CLASS: First
13. Wait for the progress bar to complete and the words INSERT DONE... to
appear.
15. From the QuickTest Professional menu bar, select INSERT >
SYNCHRONIZATION POINT after the progress bar completes. The cursor
changes to a pointed finger.
16. In the FLIGHT RESERVATION window, in the progress bar, click the
words INSERT DONE... with the pointed finger cursor. The OBJECT
SELECTION - SYNCHRONIZATION POINT dialog box appears.
21. Click OK. An INSERT DONE (Wait Property) step is added in KEYWORD
VIEW.
22. Add a standard checkpoint that uses a regular expression on the FAX
ORDER NO. window title bar. To do this:
23. From the Flight Reservation menu bar, select FILE > FAX ORDER. The
FAX ORDER NO. window appears.
24. From the QuickTest Professional menu bar, select INSERT >
CHECKPOINT > STANDARD CHECKPOINT. The cursor changes to a
pointing hand.
25. Click the FAX ORDER NO. window title bar with the pointing hand
cursor. The OBJECT SELECTION - CHECKPOINT PROPERTIES dialog box
appears.
27. In the CHECKPOINT PROPERTIES dialog box, check the TEXT check box.
Uncheck all other check boxes.
28. Select the TEXT property and ensure that the CONSTANT option is
selected.
29. Click the CONSTANT VALUE OPTIONS button next to the CONSTANT
field. The CONSTANT VALUE OPTIONS dialog box appears.
30. In the VALUE field, replace the existing text with FAX ORDER NO..*.
35. In the FAX ORDER NO. window, in the FAX NUMBER field, type
4255550150 and click SEND.
36. In the FLIGHT RESERVATION window, click the NEW ORDER button to
set the end condition.
38. Modify the object properties for the FAX ORDER NO. title bar step to use
the regular expression. To do this:
39. From the QuickTest Professional menu bar, select RESOURCES >
OBJECT REPOSITORY. The OBJECT REPOSITORY dialog box appears.
40. In the OBJECT REPOSITORY dialog box, select the FAX ORDER NO. object.
41. In the OBJECT PROPERTIES pane, select the TEXT property row.
42. Click the VALUE column. The CONFIGURE THE VALUE button appears.
43. Click the CONFIGURE THE VALUE button. The VALUE CONFIGURATION
OPTIONS dialog box appears.
44. Ensure that the CONSTANT option is selected.
45. In the CONSTANT field, replace the existing text with FAX ORDER NO..*.
2. From ACTIVE SCREEN, right-click the ORDER NO. field and select
INSERT OUTPUT VALUE.
6. Click OK.
2. Click the VALUE column and then click the CONFIGURE THE VALUE
button. The VALUE CONFIGURATION OPTIONS dialog box appears.
6. Click OK.
2. In the RUN dialog box, click OK on the default choice. The test passes.
3. Select the TICKETS step where operation is SET. This is the second
TICKETS step.
8. Check the NAME check box and in the NAME field, type TICKETS_OUT.
2. Open the LOGIN window of the Flight Reservation application. (Do not
log in yet)
3. From the QuickTest Professional menu bar, select FILE > NEW > TEST
to open a new test.
5. Click OK.
PASSWORD: mercury
3. In the ACTION PROPERTIES dialog box, from the GENERAL tab, in the
NAME field, replace ACTION1 with FLIGHT_LOGIN.
4. In the ACTION PROPERTIES dialog box, from the GENERAL tab, in the
NAME field, replace ACTION1 with FLIGHT_NEWORDER.
7. Click OK.
3. This name is an abbreviation for Flight Business process and this action
is not reusable.
5. From the QuickTest Professional menu bar, select INSERT > CALL TO
COPY OF ACTION. The SELECT ACTION dialog box appears.
11. From the QuickTest Professional menu bar, select INSERT > CALL TO
COPY OF ACTION.
12. IN THE SELECT ACTION dialog box, from the FROM TEST list, browse and
select the LABCH8_3_NEWORDER test.
14. Ensure that the AFTER THE CURRENT STEP option is selected.
18. Close the FLIGHT RESERVATION window and then launch the LOGIN
window of the application. Do not log in.
19. Run the test. The test should pass.
3. In KEYWORD VIEW, in the ITEM column, click the STATEMENT step. The
step changes to a list.
2. In the SELECT OBJECT FOR STEP dialog box, click the pointing finger
button. The cursor changes to a pointing hand.
3. Use the pointing hand cursor to click the LOGIN window. The OBJECT
SELECTION dialog box appears.
4. In the OBJECT SELECTION dialog box, click OK. This adds the LOGIN
object to the object repository tree in the SELECT OBJECT FOR STEP
dialog box.
5. Repeat steps 3 and 4 for the AGENT NAME and PASSWORD fields, and for
the OK button in the LOGIN dialog box.
6. Verify that all of the objects that you have added appear in the object
repository tree in the SELECT OBJECT FOR STEP dialog box.
8. Click OK.
3. From the QuickTest Professional menu bar, select INSERT > NEW STEP.
A new step is added.
6. Repeat the steps from 3 through 5 to add the password. In step 5, set the
password to MERCURY.
2. From the QuickTest Professional menu bar, select INSERT > REPORT.
The INSERT REPORT dialog box appears.
3. In the INSERT REPORT dialog box, from the STATUS list, select PASSED.
4. In the NAME field, type LOGIN WINDOW FOUND.
6. Click OK.
7. Close the Flight Reservation application and open it again but do not log
on.
10. View the test results to see how the REPORTER EVENT reports the test
status.
3. View the results in the TEST RESULTS window. The test results show that
the object does not exist.
4. You must prepare for the case when the LOGIN window is not found.
You can use the ELSE statement to handle this situation.
7. THE ELSE statement appears at the end of the test. Click the step with the
ELSE statement. The step changes to a list.
8. From the list, select STEP GENERATOR. The STEP GENERATOR dialog
box appears.
9. In the STEP GENERATOR dialog box, from the CATEGORY list, select
FUNCTIONS.
10. From the LIBRARY list, select ALL. The ALL function library appears.
18. From the QuickTest Professional menu bar, select INSERT > NEW STEP.
A new step is added.
19. From the list, select OBJECT FROM REPOSITORY. The SELECT OBJECT FOR
STEP dialog box appears.
20. In the SELECT OBJECT FOR STEP dialog box, in the object repository tree,
select the LOGIN window object and click OK.
22. FROM THE QUICKTEST PROFESSIONAL menu bar, select INSERT > NEW
STEP. A new step is added.
25. From the QuickTest Professional menu bar, select INSERT > NEW STEP.
A new step is added.
28. FROM THE QUICKTEST PROFESSIONAL menu bar, select INSERT > NEW
STEP. A new step is added.
TICKETS: 2
CLASS: First
2. To create an output step for the number of tickets per flight, in the
ACTIVE SCREEN, right-click the TICKETS field that is highlighted.
5. Check the TEXT check box and click MODIFY. The OUTPUT OPTIONS
dialog box appears.
1) A TICKETS step appears in KEYWORD VIEW that has the OUTPUT value in
the OPERATION column.
11. From ACTIVE SCREEN, select the PRICE field and perform steps 2
through 10 to create an output parameter NPRICE.
12. From ACTIVE SCREEN, select the TOTAL field and perform steps 2
through 10 to create an output parameter NTOTAL.
13. Double-click the fourth column in the GLOBAL sheet of DATA TABLE
that does not have a name. The CHANGE PARAMETER NAME dialog box
appears.
15. Click OK. The new column name appears in the DATA TABLE.
NTICKETS: 1
PRICE: 123
TOTAL: 123
2. For the first row under the PRICECHK column, type the following
formula:
=ROUND(A1*B1,2)=ROUND(C1,2)
4. Change the value of NTICKETS to 2 and press ENTER. The FALSE value
appears in the PRICECHK column.
2. From the QuickTest Professional menu bar, select INSERT > STEP
GENERATOR. The STEP GENERATOR dialog box appears.
6. For the PARAMETERID field, click in the VALUE column and type
PRICECHK.
5. Click OK.
8. From the QuickTest Professional menu bar, select INSERT > REPORT.
The INSERT REPORT dialog box appears.
16. In the TEST RESULTS window, check that the REPORTER EVENT step
reports the correct status based on the outcome of the test.
17. Verify that the value of PRICECHK is TRUE in RUN-TIME DATA TABLE
of the TEST RESULTS window.
Part 6: Set a Breakpoint and Create a Failure
1. In KEYWORD VIEW, select the TOTAL step that has OUTPUT as the value
in the OPERATION column.
3. Run the test. When the test run stops at the breakpoint step, change the
number of tickets in the GLOBAL sheet of the DATA TABLE to a different
number. For example, change the number of tickets from 2 to 5.
7. Expand all steps in the TEST RESULTS window to view the output of the
REPORTER step.
8. Check the values in RUN-TIME DATA TABLE to see which values passed.
TICKETS: 2
CLASS: First
14. In the FLIGHT RESERVATION window, click the NEW ORDER button to
set end conditions for the test.
15. On the QuickTest Professional toolbar, click STOP to stop the test.
18. In ACTIVE SCREEN, right-click the ORDER NO field, and select INSERT
OUTPUT VALUE to create an output parameter. The OBJECT SELECTION -
OUTPUT VALUE PROPERTIES dialog box appears.
19. Click OK. The OUTPUT VALUE PROPERTIES dialog box appears.
20. Check the TEXT check box, and click MODIFY. The OUTPUT OPTIONS
dialog box appears.
23. In the OUTPUT VALUE PROPERTIES dialog box, select the AFTER
CURRENT STEP option.
26. The KEYWORD VIEW has an ORDER NO step that has the OUTPUT value
in the OPERATION column.
27. The GLOBAL sheet of DATA TABLE has a column named
GUIORDER_NO.
30. Run the test to verify that the new order number and the number of
tickets are captured in RUN-TIME DATA TABLE.
3. In the QUERY DEFINITION section, ensure that the CREATE QUERY USING
MICROSOFT QUERY option is selected.
6. Ensure that the SHOW ME HOW TO USE MICROSOFT QUERY check box
is checked, and click NEXT.
8. In the CHOOSE DATA SOURCE dialog box, in the DATABASES list, click
QT_FLIGHT32*.
10. Ensure that the USE THE QUERY WIZARD TO CREATE/EDIT QUERIES check
box is checked.
13. From the AVAILABLE TABLES AND COLUMNS list, select the columns
ORDER_NUMBER, TICKETS_ORDERED, and AGENTS_NAME, and use
the right arrow button to add each column to the COLUMNS IN YOUR
QUERY list. Click NEXT.
14. In the QUERY WIZARD - FILTER DATA dialog box, click NEXT.
15. In the QUERY WIZARD - SORT ORDER dialog box, from the SORT BY list,
select ORDER_NUMBER.
17. In the QUERY WIZARD - FINISH dialog box, click SAVE QUERY.
18. In the SAVE AS dialog box, click SAVE to save the query by the default
query name. The QUERY WIZARD - FINISH dialog box appears.
19. Ensure that the EXIT AND RETURN TO QUICKTEST PROFESSIONAL option
is selected.
2. Click the REMOVE FROM CHECK button to uncheck all rows currently
selected.
4. Click the ADD TO CHECK button to select the first cell of the
ORDER_NUMBER column.
6. In the PARAMETER OPTIONS dialog box, from the NAME list, select
GUI_ORDER_NO and click OK.
2. Click the ADD TO CHECK button to select the first cell of the TICKETS
column.
4. In the PARAMETER OPTIONS dialog box, from the NAME list, select
NTICKETS and click OK to close the PARAMETER OPTIONS dialog box.
TICKETS: 2
CLASS: First
14. In the FLIGHT RESERVATION window, click the NEW ORDER button to
set end conditions for the test.
15. On the QuickTest Professional toolbar, click STOP to stop the test.
18. In ACTIVE SCREEN, right-click the ORDER NO field, and select INSERT
OUTPUT VALUE to create an output parameter. The OBJECT SELECTION -
OUTPUT VALUE PROPERTIES dialog box appears.
19. Click OK. The OUTPUT VALUE PROPERTIES dialog box appears.
20. Check the TEXT check box, and click MODIFY. The OUTPUT OPTIONS
dialog box appears.
23. In the OUTPUT VALUE PROPERTIES dialog box, select the AFTER
CURRENT STEP option.
26. The KEYWORD VIEW has an ORDER NO step that has the OUTPUT value
in the OPERATION column.
27. The GLOBAL sheet of DATA TABLE has a column named
GUIORDER_NO.
30. Run the test to verify that the new order number and the number of
tickets are captured in RUN-TIME DATA TABLE.
3. In the QUERY DEFINITION section, ensure that the CREATE QUERY USING
MICROSOFT QUERY option is selected.
6. Ensure that the SHOW ME HOW TO USE MICROSOFT QUERY check box
is checked, and click NEXT.
8. In the CHOOSE DATA SOURCE dialog box, in the DATABASES list, click
QT_FLIGHT32*.
10. Ensure that the USE THE QUERY WIZARD TO CREATE/EDIT QUERIES check
box is checked.
13. From the AVAILABLE TABLES AND COLUMNS list, select the columns
ORDER_NUMBER, TICKETS_ORDERED, and AGENTS_NAME, and use
the right arrow button to add each column to the COLUMNS IN YOUR
QUERY list. Click NEXT.
14. In the QUERY WIZARD - FILTER DATA dialog box, click NEXT.
15. In the QUERY WIZARD - SORT ORDER dialog box, from the SORT BY list,
select ORDER_NUMBER.
17. In the QUERY WIZARD - FINISH dialog box, click SAVE QUERY.
18. In the SAVE AS dialog box, click SAVE to save the query by the default
query name. The QUERY WIZARD - FINISH dialog box appears.
19. Ensure that the EXIT AND RETURN TO QUICKTEST PROFESSIONAL option
is selected.
2. Click the REMOVE FROM CHECK button to uncheck all rows currently
selected.
4. Click the ADD TO CHECK button to select the first cell of the
ORDER_NUMBER column.
6. In the PARAMETER OPTIONS dialog box, from the NAME list, select
GUI_ORDER_NO and click OK.
2. Click the ADD TO CHECK button to select the first cell of the TICKETS
column.
4. In the PARAMETER OPTIONS dialog box, from the NAME list, select
NTICKETS and click OK to close the PARAMETER OPTIONS dialog box.
2. From the QuickTest Professional menu bar, select INSERT > NEW STEP>
STEP GENERATOR.
a. CATEGORY: Functions
b. LIBRARY: All
c. OPERATION: InvokeApplication
5. Click OK.
6. Run the test to make sure the step produces the expected result, the
invocation of the Flights application with a Login window.
b. PASSWORD: mercury
6. While still in Record mode, from the menu bar choose INSERT>
SYNCHRONIZATION POINT
8. In the Properties dialog, choose Enabled – True for the state of the
window.
2. Click on the "configure the value" button in the password edit box.
3. Define the Data Table as the parameter type in the Global Data Sheet.
7. Execute the test. You will notice that on the second iteration, the test
encounters a pop up message indicating that an incorrect password has
been entered.
6. Use the Pointing Hand to point to the offending pop-up. Note: both the
window title and window text can be defined as a regular expression.
12. Click on pointing hand, then click on the OK button in the error message
dialog.
18. You are now back in the Recovery Operations window and the two
operations should be listed.
27. Run the test to ensure that it works as expected. You will notice that the
test “hangs”.
5. View Test Results for information about the recovery scenario usage.