Professional Documents
Culture Documents
QTP9 Step by Guide Exercises
QTP9 Step by Guide Exercises
visit www.ramupalanki.com
Exercises
Exercise: Preparing the Test Environment
box.
3. Click OK.
1. From the QuickTest Professional menu bar, select TOOLS > OPTIONS.
For more QTP Realtime Sripts, visit
www.ramupalanki.com
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
8. Click OK.
This exercise enables you to record a basic test, run and save the test, and
view results. The activities here are divided into the following parts:
PASSWORD: mercury
For more QTP Realtime Sripts, visit
www.ramupalanki.com
3. Click OK. The FLIGHT RESERVATION window appears.
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.
APPLICATION option.
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
For more QTP Realtime Sripts, visit
www.ramupalanki.com
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.
This exercise enables you to record a new test and use the various features of
the OBJECT REPOSITORY dialog box. The activities in this exercise are divided
into the following parts:
2. In the QuickTest Professional menu bar, select FILE > NEW > TEST.
For more QTP Realtime Sripts, visit
www.ramupalanki.com
3. Click RECORD. The RECORD AND RUN SETTINGS dialog box appears.
FROM: Frankfurt
NAME: Maura
TICKETS: 2
CLASS: First
From the QuickTest Professional menu bar, select RESOURCES > OBJECT
REPOSITORY. Now, answer a few questions to check your knowledge.
FLIGHT RESERVATION, FIRST, DATE OF FLIGHT, TICKETS, NAME, FLY TO, FLY
FROM, INSERT ORDER, FLIGHT, BUTTON, FLIGHTS TABLE, and OK.
Answer: Seven
After you are done, close the OBJECT REPOSITORY dialog box.
Part 3: Change the Logical Name of an Object
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
For more QTP Realtime Sripts, visit
www.ramupalanki.com
properties for the NAME field.
ENABLED ______________________
NATIVECLASS ______________________
The answers in order are:
1. Ensure that the LABCH4_3 test and the FLIGHT RESERVATION window
are open.
Answer: A temporary frame blinks around the NEW ORDER icon in the
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.
You need to cause a test to fail by changing the default timeout setting. View
the error that occurs because of this change, and correct it to ensure a
successful test run. This exercise enables you to add synchronization to your
tests. This exercise is divided into the following parts:
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.
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.
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.
16. View the test results and close the TEST RESULTS window.
Create a basic test and add STANDARD checkpoint to enhance it. Use a regular
expression to make the test more flexible. The activities in this exercise are
divided into the following parts:
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.
For more QTP Realtime Sripts, visit
www.ramupalanki.com
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.
pointing hand.
12. In the FLIGHT RESERVATION window, in the progress bar, click the
words INSERT DONE... with the pointing hand cursor. The OBJECT
14. In the CHECKPOINT PROPERTIES dialog box, check the TEXT property and
uncheck all other properties.
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)
OK.
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.
ORDER NO step.
9. On the QuickTest Professional toolbar, click RUN to run the test. The
test should pass.
1. From the QuickTest Professional menu bar, select FILE > NEW > TEST
to start a new test.
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.
For more QTP Realtime Sripts, visit
www.ramupalanki.com
3. In the OBJECT PROPERTIES pane, in the VALUE column, click to
display
4. Click the
CONFIGURE THE VALUE button. The VALUE
CONFIGURATION OPTIONS dialog box appears.
9. Click OK.
3. From the QuickTest Professional menu bar, select FILE > NEW >
For more QTP Realtime Sripts, visit
www.ramupalanki.com
TEST.
TICKETS: 2
CLASS: First
13. Wait for the progress bar to complete and the words I NSERT
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.
VIEW.
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 >
pointing hand.
25. Click the FAX ORDER NO. window title bar with the pointing hand
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.
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
For more QTP Realtime Sripts, visit
www.ramupalanki.com
4255550150 and click SEND.
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.
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
6. Click OK.
TABLE.
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
For more QTP Realtime Sripts, visit
www.ramupalanki.com
TICKETS step.
8. Check the NAME check box and in the NAME field, type TICKETS_OUT.
window.
Actions
In this exercise, you create two reusable actions to be called from a main calling
action. The activities in this exercise are divided into the following parts:
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.
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.
1. From QuickTest Professional menu bar, select FILE > NEW > TEST to
start a new test.
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.
LABCH8_1_FLIGHTLOGIN test.
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.
FLIGHT_LOGIN test.
18. Close the FLIGHT RESERVATION window and then launch the LOGIN
window of the application. Do not log in.
For more QTP Realtime Sripts, visit
www.ramupalanki.com
19. Run the test. The test should pass.
Create a test that searches for the LOGIN window. If the window is found, enter
the appropriate user name and password and report that the login was
successful. If the window is not found, report an error and launch the Flight
Reservation application. If the objects for the test application are not available,
add them to Object Repository. The activities in this exercise are divided into
the following parts:
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.
EXIST.
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.
3. In the INSERT REPORT dialog box, from the STATUS list, select PASSED.
4. In the NAME field, type LOGIN WINDOW FOUND.
LOGIN IS SUCCESSFUL.
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.
For more QTP Realtime Sripts, visit
www.ramupalanki.com
5. In KEYWORD VIEW, select the IF statement.
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.
PROFESSIONAL\SAMPLES\FLIGHT\APP\FLIGHT4A.EXE.
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
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
In this exercise, you create a test to verify that the calculated total cost of
tickets purchased for a flight reservation is correct. You use breakpoints to
force the outcome of the total amount. You also use breakpoints to verify that
the correct reporter message appears, based on the result of the calculation.
This exercise consists of the following parts:
TICKETS: 2
CLASS: First
1. From KEYWORD VIEW, select the TICKETS step that has the SET value in
the OPERATION column.
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.
TABLE.
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.
1. In the GLOBAL sheet of DATA TABLE, specify test data for the following
fields:
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.
1. In KEYWORD VIEW, select the TOTAL step that has the OUTPUT value in
the OPERATION 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.
VPRICECHK=”TRUE”.
5. Click OK.
highlighted.
8. From the QuickTest Professional menu bar, select INSERT > REPORT.
The INSERT REPORT dialog box appears.
SUCCESSFULLY.
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.
For more QTP Realtime Sripts, visit
www.ramupalanki.com
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.
INSERT/REMOVE BREAKPOINT.
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.
In this exercise, you create a test to verify that an order number generated in the
Flight Reservation application is inserted into the QT_FLIGHTS32 database. You
also verify that the number of tickets ordered matches the number of tickets
stored in the QT_FLIGHTS32 database for an order number.
TICKETS: 2
CLASS: First
15. On the QuickTest Professional toolbar, click STOP to stop the test.
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
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.
1. In KEYWORD VIEW, select the TICKETS step that has the value OUTPUT
in the OPERATION column.
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
For more QTP Realtime Sripts, visit
www.ramupalanki.com
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.
12. In the QUERY WIZARD - CHOOSE COLUMNS dialog box, in the AVAILABLE
TABLES AND COLUMNS list, double-click the ORDERS table to display all
columns of the table.
13. From the AVAILABLE TABLES AND COLUMNS list, select the columns
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.
displays a table that shows the result set of the SQL query.
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
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.
In this exercise, you create a test to verify that an order number generated in the
Flight Reservation application is inserted into the QT_FLIGHTS32 database. You
also verify that the number of tickets ordered matches the number of tickets
stored in the QT_FLIGHTS32 database for an order number.
TICKETS: 2
CLASS: First
15. On the QuickTest Professional toolbar, click STOP to stop the test.
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
26. The KEYWORD VIEW has an ORDER NO step that has the OUTPUT
value in the OPERATION column.
For more QTP Realtime Sripts, visit
www.ramupalanki.com
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.
1. In KEYWORD VIEW, select the TICKETS step that has the value OUTPUT
in the OPERATION column.
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.
12. In the QUERY WIZARD - CHOOSE COLUMNS dialog box, in the AVAILABLE
TABLES AND COLUMNS list, double-click the ORDERS table to display all
columns of the table.
13. From the AVAILABLE TABLES AND COLUMNS list, select the columns
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.
displays a table that shows the result set of the SQL query.
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
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.
In this exercise, you will create a test that encounters an error during playback. You
will then create a recovery scenario to correct the problem when the automated test
runs.
2. From the QuickTest Professional menu bar, select INSERT > NEW STEP>
STEP GENERATOR.
a. CATEGORY: Functions
b. LIBRARY: All
c. OPERATION: InvokeApplication
Professional\samples\flight\app\flight4a.exe".
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
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.
For more QTP Realtime Sripts, visit
www.ramupalanki.com
7. Click the NEXT button.
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.