qtp9 step by guide exercises
TRANSCRIPT
-
8/8/2019 QTP9 Step by Guide Exercises
1/97
For more QTP Realtime Sripts,
visit www.ramupalanki.com
QuickTest Professional 9.0
Exercises
-
8/8/2019 QTP9 Step by Guide Exercises
2/97
Exercise: Preparing the Test Environment
Use the Windows -based Flight Reservation application to prepare forrecording. 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.
Part 1: Launch QuickTest Professional 9.0.
Part 2: Set QuickTest test options.
Part 1: Launch QuickTest Professional 9.0
1. ClickSTART > PROGRAMS > QUICKTESTPROFESSIONAL >
QUICKTEST PROFESSIONAL.
2. ENSURE ALL OPTIONS ARE UNCHECKED IN THE ADD-IN MANAGERdialog
box.
3. Click OK.
4. IN THE QUICKTEST PROFESSIONAL window, clickBLANKTEST.
Part 2: Set QuickTest Test Options
1. From the QuickTest Professional menu bar, select TOOLS > OPTIONS.
-
8/8/2019 QTP9 Step by Guide Exercises
3/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com2. IN THE GENERAL tab, clickRESTORELAYOUT to ensure that the layout is
uniform and all panes and toolbars are displayed in their default
positions and sizes.
3. Click the RUN tab.
4. Ensure that the NORMAL option is selected.
5. Ensure that the VIEW RESULTS WHEN RUN SESSION ENDS check box is
unchecked.
6. Ensure that the ALLOW OTHERMERCURY PRODUCTS TO RUN TESTS AND
COMPONENTS check box is unchecked.
7. From the SAVE STEP SCREEN CAPTURE TO RESULTS list, select ON
ERRORS AND WARNINGS.
8. Click OK.
9. CLOSE THE QUICKTEST PROFESSIONAL APPLICATION.
-
8/8/2019 QTP9 Step by Guide Exercises
4/97
Exercise: Creating a Basic Test
This exercise enables you to record a basic test, run and save the test, andview results. The activities here are divided into the following parts:
Part 1: Set initial conditions.
Part 2: Record the business process.
Part 3: Save the test.
Part 4: Run the test.
Part 5: View results.
Part 1: Set Initial Conditions
1. Invoke the Flight Reservation application by selecting START >
PROGRAMS> QUICKTEST PROFESSIONAL> SAMPLE APPLICATIONS>
FLIGHT.
2. Log in using the following information:
AGENT NAME: Mercury
PASSWORD: mercury
-
8/8/2019 QTP9 Step by Guide Exercises
5/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com3. ClickOK. The FLIGHT RESERVATION window appears.
4. From the QuickTest Professional menu bar, select FILE > NEW >
TEST.
5. On the QuickTest Professional toolbar, clickRECORD. The RECORD
AND RUN SETTINGS dialog box appears.
6. Start and end recording from the FLIGHT RESERVATION window to set
the window as the initial and end condition for the test.
7. Select the RECORD AND RUN TEST ON ANY OPENWINDOWS-BASED
APPLICATION option.
8. ClickOK. Ensure a blinking RECORDING message appears in the
lower right of the QUICKTEST PROFESSIONAL window.
Notice that the QUICKTEST PROFESSIONAL window has resized for recording.
-
8/8/2019 QTP9 Step by Guide Exercises
6/97
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.
Part 2: Record the Business Process
1. Click the FLIGHT RESERVATION window to activate it.
2. On the FLIGHT RESERVATION toolbar, click the NEWORDERicon to set
the initial condition. Notice that a step is added in the KEYWORD VIEW.
3. Specify the following flight data:
DATE: 11-11-09
FLY FROM: DENVER
FLY TO: SEATTLE
4. Click FLIGHTS. The FLIGHTS TABLE appears.
5. On the default choice, clickOK.
6. Specify the following:
NAME: SAM SMITH
TICKETS: 2
-
8/8/2019 QTP9 Step by Guide Exercises
7/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com
CLASS: FIRST
7. ClickINSERTORDER. Wait for the progress bar to complete. When theinsertion is complete, the INSERT DONE... message appears.
8. On the FLIGHT RESERVATION toolbar, click the NEWORDERicon to set
the end condition.
9. On the QuickTest Professional toolbar, clickSTOP to stop the test.
-
8/8/2019 QTP9 Step by Guide Exercises
8/97
Part 3: Save the Test
1. In the QUICKTEST PROFESSIONAL window, select FILE> SAVE. TheSAVE TEST dialog box appears.
2. Browse to the directory \QTP90USING\TESTS.
3. In the FILE NAME field, type LABCH3_3.
4. ClickSAVE.
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.
Part 4: Run the Test
1. On the toolbar, click RUN.
2. ClickOKto use the TEMPORARY RUN RESULTS FOLDER.
3. Observe the run of the business process.
Part 5: View Results
1. After the test run completes, on the QuickTest Professional toolbar,
click the RESULTS button.
-
8/8/2019 QTP9 Step by Guide Exercises
9/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com2. From the tree on the left side of TEST RESULTS window, right-click the
TEST SUMMARY node and select EXPAND ALL.
3. View the results.
4. CLOSE THE TEST RESULTS window and QuickTest Professional.
-
8/8/2019 QTP9 Step by Guide Exercises
10/97
Exercise: Using the Object Repository
This exercise enables you to record a new test and use the various features ofthe OBJECT REPOSITORY dialog box. The activities in this exercise are divided
into the following parts:
Part 1: Record a new order.
Part 2: Open the OBJECT REPOSITORY dialog box.
Part 3: Change the logical name of an object.
Part 4: Use the Object Spy feature.
Part 5: Use the Highlight feature.
Part 6: Use the Locate in Repository feature.
Part 7: Add a new object.
Part 1: Record a New Order
1. Ensure that the QuickTest Professional and Flight Reservation
applications are open on your computer.
2. In the QuickTest Professional menu bar, select FILE > NEW > TEST.
-
8/8/2019 QTP9 Step by Guide Exercises
11/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com3. ClickRECORD. The RECORD AND RUN SETTINGS dialog box appears.
4. In the RECORD AND RUN SETTINGS dialog box, clickOK.
5. In the FLIGHT RESERVATION window toolbar, clickNEWORDER
button to set the initial condition.
6. Enter the following flight data:
DATE OF FLIGHT: 12-12-09 FLY
FROM: Frankfurt
FLY TO: London
7. Click Flights. The FLIGHTS TABLE appears.
8. Click OKto accept the default choice.
-
8/8/2019 QTP9 Step by Guide Exercises
12/97
9. Enter the following purchase data:
NAME: Maura
TICKETS: 2
CLASS: First
10. ClickNEWORDER.
11. On the FLIGHT RESERVATION window toolbar, clickNEWORDER to
set end conditions.
12. On the QuickTest Professional toolbar, clickSTOP to end the
recording session.
13. Save the test as LABCH4_1.
Part 2: Open the Object Repository Dialog Box
From the QuickTest Professional menu bar, select RESOURCES > OBJECT
REPOSITORY. Now, answer a few questions to check your knowledge.
1. How many objects can you identify in the Object Repository?
-
8/8/2019 QTP9 Step by Guide Exercises
13/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com
Answer: 11 or 12 if the OK button is counted.
FLIGHT RESERVATION, FIRST, DATE OF FLIGHT, TICKETS, NAME, FLY TO, FLY
FROM, INSERT ORDER, FLIGHT, BUTTON, FLIGHTS TABLE, and OK.
2. How many different classes of objects can you identify?
Answer: Seven
FLIGHT RESERVATION, FIRST, DATE OF FLIGHT, (TICKETSand NAME), (FLY TO
and FLYFROM), (INSERTORDER, FLIGHT, and BUTTON), and FLIGHTSTABLE.
3. How many objects of the class WinButton are shown?
Answer: Three (or four if the OK button is counted).
INSERT ORDER, FLIGHT, and BUTTON.
After you are done, close the OBJECT REPOSITORY dialog box.
-
8/8/2019 QTP9 Step by Guide Exercises
14/97
Part 3: Change the Logical Name of an Object
1. From the QuickTest Professional menu bar, select RESOURCES >
OBJECT REPOSITORY. The OBJECTREPOSITORYdialog box appears.
2. In the OBJECT REPOSITORY tree, right-click the BUTTON object.
3. From the menu, select RENAME.
4. TYPE THE NEW NAME ASNEWORDER.
5. Press ENTER.
6. CLOSE THE OBJECT REPOSITORY dialog box.
7. Save the test as LABCH4_3.
Part 4: Use the Object Spy Feature
1. Ensure that the FLIGHT RESERVATION window is open.
2. On the QuickTest Professional toolbar, click the OBJECTSPY button.
The OBJECT SPY dialog box appears.
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
-
8/8/2019 QTP9 Step by Guide Exercises
15/97
For more QTP Realtime Sripts, visit
www.ramupalanki.comproperties for the NAME field.
5. Document the following object property values:
CLASS NAME ______________________
ENABLED ______________________
ATTACHED TEXT _____________________
NATIVECLASS ______________________
-
8/8/2019 QTP9 Step by Guide Exercises
16/97
The answers in order are:
WIN
EDIT
, TRUE
, NAME
, EDIT
6. Close the OBJECT SPY dialog box.
Part 5: Use the Highlight Feature
1. Ensure that the LABCH4_3 test and the FLIGHT RESERVATION window
are open.
2. From the QuickTest Professional menu bar, select RESOURCES>
OBJECT REPOSITORY. The OBJECTREPOSITORYdialog box appears.
3. In the OBJECT REPOSITORY tree, select the NEWORDERobject.
4. Click the HIGHLIGHT INAPPLICATION button.
5. Observe the FLIGHTS RESERVATION window. What did you observe?
Answer: A temporary frame blinks around the NEW ORDERicon in the
FLIGHT RESERVATION window.
Part 6: Use the Locate in Repository Feature
1. On the OBJECT REPOSITORY toolbar, click the LOCATE INREPOSITORY
button. The cursor changes to a pointing hand.
-
8/8/2019 QTP9 Step by Guide Exercises
17/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com
2. In the FLIGHTS RESERVATION window, use the pointing hand cursor to
point to the NEW ORDERbutton and click the NEWORDERbutton. The
SELECT AN OBJECT dialog box appears.
3. Click OK. What did you observe?
Answer: The NEW ORDERobject is highlighted in the OBJECT REPOSITORY
dialog box.
Part 7: Add a New Object
1. In the OBJECT REPOSITORY tree, select the FLIGHT object.
2. On the Object Repository toolbar, click the DEFINENEWTESTOBJECT
button. The DEFINE NEW TEST OBJECT dialog box appears.
Alternatively, select OBJECT> DEFINENEWTESTOBJECT.
3. From the ENVIRONMENT list, select STANDARDWINDOWS.
-
8/8/2019 QTP9 Step by Guide Exercises
18/97
4. From the CLASS list, select WINBUTTON.
5. In the NAME field, type OK.
6. In the TEST OBJECT DETAILS section, click the VALUE column for
the TEXTproperty, and typeOK.
7. ClickADD to add the new test object to the local object repository.
8. ClickCLOSE to close the DEFINE NEW TEST OBJECT dialog box. A
new object is added under the FLIGHT object.
9. Close the OBJECT REPOSITORY dialog box.
10. Save the test as LABCH4_7.
11. Close the QuickTest Professional and Flight Reservation
applications.
-
8/8/2019 QTP9 Step by Guide Exercises
19/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com
Exercise: Adding Synchronization
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:
Part 1: Change default synchronization timeout for a test.
Part 2: Run the modified test.
Part 3: Correct the error by inserting a synchronization point.
Part 1: Change Default Synchronization Timeout for
a Test
1. Invoke the QuickTest Professional and Flight Reservation applications.
2. From the QuickTest Professional menu bar, select FILE > NEW > TEST
to open a new test.
3. On the QuickTest Professional toolbar, click the SETTINGS button.
4. In the TEST SETTINGS dialog box that appears, click the RUN tab.
5. In the OBJECT SYNCHRONIZATION TIMEOUT field, lower the
synchronization time from the default to 3 seconds.
-
8/8/2019 QTP9 Step by Guide Exercises
20/97
6. Click OK.
7. On the QuickTest Professional toolbar, clickRECORD.
8. In the RECORD AND RUN SETTINGS dialog box, clickOK.
9. On the Flight Reservation toolbar, click the NEWORDERicon to set
initial conditions for the test.
10. Type the following flight
data: DATE OF FLIGHT: 12-12-
09 FLY FROM: Frankfurt
FLY TO: London
11. Click FLIGHTS. The FLIGHTS TABLE appears.
-
8/8/2019 QTP9 Step by Guide Exercises
21/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com12. ClickOKto accept the default choice.
13. Type the following purchase data:
NAME: MAURA
TICKETS: 2
Class: FIRST
14. Click INSERT ORDER.
15. Wait until the INSERT DONE... message appears.
16. On the Flight Reservation toolbar, clickNEWORDERto set end
conditions.
17. On the QuickTest Professional toolbar, clickSTOP to stop recording.
18. Save the test as LABCH5_1.
Part 2: Run the Modified Test
1. On the QuickTest Professional toolbar, clickRUN.
2. In the RUN dialog box, ensure that the TEMPORARY RUN RESULTS FOLDER
option is selected.
-
8/8/2019 QTP9 Step by Guide Exercises
22/97
3. ClickOK. The test should fail. A RUN ERRORmessage box appears.
4. Notice the type of error message and close the RUN ERRORmessage box.
Error is: OBJECT IS DISABLED
Part 3: Correct the Error by Inserting a Synchronization
Point
1. Ensure that the LABCH5_1 test is open and save it as LABCH5_3.
2. In KEYWORD VIEW, select the INSERTORDERstep.
3. On the QuickTest Professional toolbar, clickRECORD.
4. To insert a synchronization point on the progress bar, from the menu
bar, select INSERT> SYNCHRONIZATIONPOINT. The cursor changes to a
pointed finger.
-
8/8/2019 QTP9 Step by Guide Exercises
23/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com5. In the progress bar, click the words INSERTDONE... with the pointed
finger cursor. The OBJECT SELECTION - SYNCHRONIZATION POINT dialog
box appears.
6. In the OBJECT SELECTION - SYNCHRONIZATION POINT dialog box,
click
OK. The ADDSYNCHRONIZATIONPOINTdialog box appears.
7. From the PROPERTY NAME list, select TEXT.
8. In the PROPERTY VALUE field, type "INSERTDONE...".
9. Retain the default timeout of 10000 milliseconds.
10. ClickOK.
11. On the QuickTest Professional toolbar, click STOP to stop
recording.
12. Save the test.
13. On the QuickTest Professional toolbar, clickRUN to run the test.
The RUN dialog box appears.
14. ClickOKto close the RUN dialog box. The test should succeed.
15. On the QuickTest Professional toolbar, click the RESULTS icon to
-
8/8/2019 QTP9 Step by Guide Exercises
24/97
view the test results. The TEST RESULTS window appears.
16. View the test results and close the TEST RESULTS window.
17. Close the test.
-
8/8/2019 QTP9 Step by Guide Exercises
25/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com
Exercise: Adding Checkpoints
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:
Part 1: Insert a standard checkpoint.
Part 2: Check the test results.
Part 3: Modify the test.
Part 4: Record and open a Fax Order test.
Part 5: Add a comment.
Part 6: Run the test.
Part 7: Modify and run the test.
Part 8: Fix the test.
Part 1: Insert a Standard Checkpoint
1. In QuickTest Professional, open a new test.
-
8/8/2019 QTP9 Step by Guide Exercises
26/97
2. Ensure that the FLIGHT RESERVATION window is open.
3. On the QuickTest Professional toolbar, clickRECORD. The RECORD AND
RUN SETTINGS dialog box appears.
4. ClickOKto close the he RECORD AND RUN SETTINGS dialog box.
5. In the FLIGHT RESERVATION window, click the NEWORDERbutton to
set the initial condition.
6. Enter the following flight
data: DATE OF FLIGHT: 11-11-
09 FLY FROM: Denver
FLY TO: Seattle
7. Click the FLIGHTS button. The FLIGHTS TABLE dialog box appears.
8. In the FLIGHTS TABLE dialog box, clickOKto accept the default choice.
-
8/8/2019 QTP9 Step by Guide Exercises
27/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com
9. Enter the following
information: NAME: Sam Smith
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.
11. In the QUICKTEST PROFESSIONAL window, select INSERT >
CHECKPOINT> STANDARD CHECKPOINT. The cursor changes to a
pointing hand.
12. In the FLIGHT RESERVATION window, in the progress bar, click the
words INSERTDONE... with the pointing hand cursor. The OBJECT
SELECTION - CHECKPOINT PROPERTIES dialog box appears.
13. In the OBJECT SELECTION - CHECKPOINT PROPERTIES dialog box, click
OK. The CHECKPOINTPROPERTIESdialog box appears.
14. In the CHECKPOINT PROPERTIES dialog box, check the TEXT property anduncheck all other properties.
15. ClickOK.
-
8/8/2019 QTP9 Step by Guide Exercises
28/97
16. IN THE FLIGHT RESERVATION toolbar, click the NEWORDERbutton to
set end condition for the test.
17. On the QuickTest Professional toolbar, clickSTOP to stop the test.
18. Save the test as LABCH6_1.
Part 2: Check the Test Results
1. On the QuickTest Professional toolbar, click RUN to run the test.
2. In the RUN dialog box, clickOK. The TEST RESULTS window appears.
3. In the TEST RESULTS window, expand the TESTSUMMARY 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.
4. Close the TESTRESULTS window.
-
8/8/2019 QTP9 Step by Guide Exercises
29/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com
Part 3: Modify the Test
1. In KEYWORD VIEW, select the last BUTTON step that appears.
2. In ACTIVE SCREEN, the ORDERNO: field must show the number
generated after the insert done operation.
3. In ACTIVE SCREEN, right-click the ORDERNO: field (not on static text)
and select INSERTSTANDARDCHECKPOINT. The OBJECT SELECTION -
CHECKPOINT PROPERTIES dialog box appears.
4. In the OBJECT SELECTION - CHECKPOINT PROPERTIES dialog box, click
OK.
5. In the CHECKPOINT PROPERTIES dialog box, uncheck all the checkboxes except TEXT.
6. Ensure that when you select the TEXT property, the ORDERNO appears
in the CONSTANT field.
7. Click OK.
8. SAVE THE TEST ASLABCH6_3.
9. On the QuickTest Professional toolbar, clickRUN to run the test. The
test should fail.
-
8/8/2019 QTP9 Step by Guide Exercises
30/97
10. View the test results. The test failed. In the next lab, you will
correct for the failure.
Part 3(a): Add a Regular Expression
1. In QUICKTEST PROFESSIONAL window, in KEYWORD VIEW, select the
ORDERNOstep.
2. In the ORDERNO row, select the VALUE column. The CHECKPOINT
PROPERTIES button appears.
3. Click the CHECKPOINTPROPERTIES button. The CHECKPOINT
PROPERTIES dialog box appears.
4. Click the CONSTANTVALUEOPTIONS button beside the CONSTANT
field. The CONSTANT VALUE OPTIONS dialog box appears.
5. In the CONSTANT VALUE OPTIONS dialog box, click the REGULAR
EXPRESSIONcheck box.
-
8/8/2019 QTP9 Step by Guide Exercises
31/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com6. Type [0-9]+ in the VALUE field and clickOK.
7. In the CHECKPOINT PROPERTIES dialog box, clickOK.
8. Save test as LABCH6_3_A.
9. On the QuickTest Professional toolbar, clickRUN to run the test. The
test should pass.
Part 4: Record and Open a Fax Order Test
1. From the QuickTest Professional menu bar, select FILE > NEW > TEST
to start a new test.
2. ClickRECORD. The RECORD AND RUN SETTINGS dialog box appears.
3. In the RECORD AND RUN SETTINGS dialog box, clickOK.
4. In the FLIGHT RESERVATION window, click the NEWORDERbutton to
set the initial conditions.
5. From the FLIGHT RESERVATION menu bar, select FILE > OPENORDER.
The OPEN ORDERwindow appears.
6. In the OPEN ORDERwindow, check the ORDERNO. check box.
7. In the ORDERNO. field, type 3.
8. CLICKOK.
-
8/8/2019 QTP9 Step by Guide Exercises
32/97
9. FROM THE FLIGHT RESERVATION menu bar, select FILE > FAXORDER.
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.
12. IN THE CHECKPOINT PROPERTIES dialog box, clickOK.
13. IN THE FAX ORDERNO. 3 window, clickCANCEL.
14. IN THE FLIGHT RESERVATION window, click the NEWORDERbutton to
set end conditions.
15. Stop recording.
-
8/8/2019 QTP9 Step by Guide Exercises
33/97
For more QTP Realtime Sripts, visit
www.ramupalanki.comPart 5: Add a Comment
1. Maximize the QUICKTEST PROFESSIONAL window.
2. Check whether the COMMENT column is visible in KEYWORD VIEW.
3. If the COMMENT column is not visible, right-click any column name in
KEYWORD VIEW and from the menu, select COMMENT.
4. In KEYWORD VIEW, select the ORDERNO. step.
5. Click the COMMENT column. Type AUNIQUE ORDER IS GENERATED
EVERY TIME YOU INSERT AN ORDER.in the COMMENTcolumn.
6. Save the test as LABCH6_5.
Part 6: Run the Test
1. On the QuickTest Professional toolbar, click RUN to run the test.
2. In the RUN dialog box, clickOK.
3. On the QUICKTEST toolbar, click the RESULTS button to check the test
results. The TEST RESULTS window appears. The test should pass.
4. Close the TEST RESULTS window.
-
8/8/2019 QTP9 Step by Guide Exercises
34/97
Part 7: Modify and Run the Test
1. In KEYWORD VIEW, select the EDIT step.
2. Change the value in the VALUE column from 3 to 7.
3. Save the test as LABCH6_7.
4. Run the test. It should fail.
5. View the test results. The test failed. In the next lab you will correct the
problem.
Part 8: Add a Regular Expression to Fix the Test
1. On the QuickTest Professional toolbar, select RESOURCES > OBJECT
REPOSITORY. The OBJECTREPOSITORYdialog box appears.
2. In the OBJECT REPOSITORY tree, select the FAXORDERNO. 3 object.
-
8/8/2019 QTP9 Step by Guide Exercises
35/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com3. In the OBJECT PROPERTIES pane, in the VALUE column, click to
display
the CONFIGURE THE VALUE button.
4. Click the CONFIGURE THE VALUE button. The VALUE
CONFIGURATION OPTIONS dialog box appears.
5. Ensure that the CONSTANT option is selected.
6. In the CONSTANT field, type .*.
7. Check the REGULAREXPRESSION check box. A dialog box appears.
8. In the dialog box, clickNO.
9. Click OK.
10. Close the OBJECT REPOSITORY dialog box.
11. Save the test as LABCH6_8.
12. Run the test.
13. View the test results. The test should pass.
14. Close the Test Results window.
-
8/8/2019 QTP9 Step by Guide Exercises
36/97
Exercise: Adding Parameters
This exercise requires you to add a checkpoint, a synchronization point, andregular expressions to a recorded test. In addition, you use input parameters,
output parameters, and regular expressions to modify the parameters, and a
random number parameter to enhance your tests. The activities in this
exercise are divided into the following parts:
Part 1: Record a new order, add a synchronization point, and a checkpoint.
Part 2: Create an output parameter from ACTIVE SCREEN.
Part 3: Parameterize to accept input values.
Part 4: Run the test.
Part 5: Use a random number parameter.
Part 1: Record a New Order, Add a Synchronization
Point, and a Checkpoint
1. Ensure that QuickTest Professional is running and no add-ins
are selected.
2. Ensure that Flight Reservation application is running and you are
logged on.
3. From the QuickTest Professional menu bar, select FILE > NEW >
-
8/8/2019 QTP9 Step by Guide Exercises
37/97
For more QTP Realtime Sripts, visit
www.ramupalanki.comTEST.
4. On the QuickTest Professional toolbar, click the RECORD button.
5. In the RECORD AND RUN SETTINGS dialog box, clickOK.
6. Click the FLIGHTRESERVATION window to activate it.
7. In the FLIGHT RESERVATION window, click the NEWORDERbutton to
set initial conditions.
8. Specify the following flight
data: DATE OF FLIGHT: 12-12-09
FLY FROM: Frankfurt
FLY TO: London
-
8/8/2019 QTP9 Step by Guide Exercises
38/97
9. Click the FLIGHTS button. The FLIGHTS TABLE window appears.
10. In the FLIGHTS TABLE window, clickOK.
11. Specify the following transaction data:
NAME: Jane Jenkins
TICKETS: 2
CLASS: First
12. Click INSERT ORDER.
13. Wait for the progress bar to complete and the words INSERT
DONE... to appear.
14. Insert a synchronization point on the INSERT ORDER... step. To do
this:
15. From the QuickTest Professional menu bar, select INSERT >
SYNCHRONIZATION POINTafter the progress bar completes. The
cursorchanges to a pointed finger.
16. In the FLIGHT RESERVATION window, in the progress bar, clickthe words INSERTDONE... with the pointed finger cursor. The
OBJECT
SELECTION - SYNCHRONIZATION POINT dialog box appears.
17. In the OBJECT SELECTION - SYNCHRONIZATION POINT dialog box,
-
8/8/2019 QTP9 Step by Guide Exercises
39/97
For more QTP Realtime Sripts, visit
www.ramupalanki.comclick
OK. The ADDSYNCHRONIZATIONPOINTdialog box appears.
18. From the PROPERTY NAME list, select TEXT.
19. In the PROPERTY VALUE field, type "INSERTDONE...".
20. Retain the default timeout of 10000 milliseconds.
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 ORDERNO. window title bar. To do this:
23. From the Flight Reservation menu bar, select FILE > FAXORDER.
The FAX ORDERNO. window appears.
24. From the QuickTest Professional menu bar, select INSERT >
CHECKPOINT> STANDARD CHECKPOINT. The cursor changes to a
pointing hand.
-
8/8/2019 QTP9 Step by Guide Exercises
40/97
25. Click the FAXORDERNO. window title bar with the pointing hand
cursor. The OBJECT SELECTION - CHECKPOINT PROPERTIES dialog box
appears.
26. In the OBJECT SELECTION - CHECKPOINT PROPERTIES dialog box, click
OK. The CHECKPOINTPROPERTIESdialog 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 FAXORDERNO..*.
31. Check the REGULAR EXPRESSION check box.
32. In the dialog box that appears, clickNO.
33. ClickOK.
34. In the CHECKPOINT PROPERTIES dialog box, clickOK.
35. In the FAX ORDERNO. window, in the FAX NUMBERfield, type
-
8/8/2019 QTP9 Step by Guide Exercises
41/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com
4255550150 and clickSEND.
36. In the FLIGHT RESERVATION window, click the NEW ORDER
button to set the end condition.
37. On the QuickTest Professional toolbar, clickSTOP.
38. Modify the object properties for the FAX ORDERNO. title bar step to
use the regular expression. To do this:
39. From the QuickTest Professional menu bar, select RESOURCES >
OBJECT REPOSITORY. The OBJECTREPOSITORYdialog 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.
-
8/8/2019 QTP9 Step by Guide Exercises
42/97
44. Ensure that the CONSTANT option is selected.
45. In the CONSTANT field, replace the existing text with FAXORDERNO..*.
46. Check the REGULAR EXPRESSION check box.
47. In the dialog box that appears, clickNO.
48. In the VALUE CONFIGURATION OPTIONS dialog box, clickOK.
49. Close the OBJECT REPOSITORY dialog box.
50. Save the test as LABCH7_1.
51. Run the test.
52. On the QuickTest Professional toolbar, click the RESULTS button to
view the test results. The test should pass.
Part 2: Create an Output Parameter from Active Screen
1. In KEYWORD VIEW, select the step INSERTDONE.
2. From ACTIVE SCREEN, right-click the ORDERNO. field and select
INSERT OUTPUT VALUE.
3. IN THE OBJECT SELECTION - OUTPUT VALUE PROPERTIES dialog box,
-
8/8/2019 QTP9 Step by Guide Exercises
43/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com
clickOK. The OUTPUT VALUE PROPERTIES dialog box appears.
4. Check the TEXT check box.
5. Select the AFTER CURRENT STEP option.
6. Click OK.
7. Ensure that a column called ORDER_NO_TEXT_OUT appears in DATA
TABLE.
8. Save the test as LABCH7_2.
Part 3: Parameterize to Accept Input Values
1. In KEYWORD VIEW, under the first occurrence of FLIGHT RESERVATION,
select the NAME step.
2. Click the VALUE column and then click the CONFIGURE THE VALUE
button. The VALUE CONFIGURATION OPTIONS dialog box appears.
3. Select the PARAMETERoption.
-
8/8/2019 QTP9 Step by Guide Exercises
44/97
4. In the NAME field, replace the existing value with NAME.
5. Ensure that the GLOBAL SHEET option is selected.
6. Click OK.
7. In the QUICKTEST PROFESSIONAL window, in DATA TABLE, in the NAME
column, type SAM, LAURENCE, and CATHERINE in three rows.
8. Save the test as LABCH7_3.
Part 4: Run the Test
1. On the QuickTest Professional toolbar, click RUN.
2. In the RUN dialog box, clickOKon the default choice. The test passes.
3. View the test results.
Part 5: Use a Random Number Parameter
1. Ensure that the test LABCH7_3 is open.
2. In KEYWORD VIEW, select the TICKETS step.
3. Select the TICKETS step where operation is SET. This is the second
-
8/8/2019 QTP9 Step by Guide Exercises
45/97
For more QTP Realtime Sripts, visit
www.ramupalanki.comTICKETS step.
4. In the VALUE column, click to display the CONFIGURE THE VALUE
button.
5. Click the CONFIGURE THE VALUE button. The VALUE CONFIGURATION
OPTIONS dialog box appears.
6. In the VALUE CONFIGURATION OPTIONS dialog box, change the
parameter type from DATATABLE to RANDOMNUMBER.
7. CHANGE THE NUMERIC RANGE from 0 to 100 to 1 to 10.
8. Check the NAME check box and in the NAME field, type TICKETS_OUT.
9. Ensure that the FOR EACH ACTION ITERATION option is selected.
10. CLICKOK.
11. Save the test as LABCH7_4.
12. Run the test.
-
8/8/2019 QTP9 Step by Guide Exercises
46/97
13. On the QuickTest Professional toolbar, click the RESULTS button.
The TEST RESULTS window appears. The output is displayed in
RUN-TIME
DATA TABLE in the ORDER_NO_TEXT_OUT column of the TEST RESULTS
window.
14. Close the QuickTest Professional and Flight Reservation
applications.
-
8/8/2019 QTP9 Step by Guide Exercises
47/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com
Exercise: Using Multiple and Reusable
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:
Part 1: Create a reusable log in test.
Part 2: Change the default name of an action.
Part 3: Create a reusable NewOrder test.
Part 5: Create a main calling test.
Part 1: Create a Reusable Log in Test
1. Ensure that the QuickTest Professional application is open.
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.
4. On the QuickTest Professional toolbar, clickRECORD. The RECORD AND
RUN SETTINGS dialog box appears.
-
8/8/2019 QTP9 Step by Guide Exercises
48/97
5. Click OK.
6. In the LOGIN dialog box, type the following information:
AGENT NAME: Alex
PASSWORD: mercury
1. ClickOK. The FLIGHT RESERVATION window appears.
2. On the QuickTest Professional toolbar, clickSTOP to stop the test.
3. Save the test as LABCH8_1_FLIGHTLOGIN.
4. Close the FLIGHT RESERVATION window.
5. Select START > PROGRAMS > QUICKTESTPROFESSIONAL > SAMPLE
APPLICATIONS> FLIGHT. The LOGINdialog box appears.
-
8/8/2019 QTP9 Step by Guide Exercises
49/97
For more QTP Realtime Sripts, visit
www.ramupalanki.comRun the test and verify that the test passes.
Part 2: Change the Default Name of the Action
1. Ensure that the LABCH8_1_FLIGHTLOGIN test is open.
2. In KEYWORD VIEW, right-click the ACTION1 step and select ACTION
PROPERTIES from the menu. The ACTION PROPERTIES dialog box
appears.
3. In the ACTION PROPERTIES dialog box, from the GENERAL tab, in theNAME field, replace ACTION1 with FLIGHT_LOGIN.
4. Check the REUSABLE ACTION check box.
5. ClickOK. The HINT dialog box appears.
6. In the HINT dialog box, clickOK.
7. Save the test.
Part 3: Create a Reusable NewOrder Test
1. Open a new test.
2. Record a new test to insert an order.
3. IN QUICKTEST PROFESSIONAL, IN KEYWORD VIEW, right-click the
-
8/8/2019 QTP9 Step by Guide Exercises
50/97
ACTION1 step and select ACTION PROPERTIES from the menu. The
ACTION PROPERTIES dialog box appears.
4. In the ACTION PROPERTIES dialog box, from the GENERAL tab, in theNAME field, replace ACTION1 with FLIGHT_NEWORDER.
5. In the DESCRIPTION field, type CREATE A NEW ORDER.
6. Check the REUSABLE ACTION check box.
7. Click OK.
8. In the HINT dialog box, clickOK.
9. Save the test as LABCH8_3_NEWORDER.
-
8/8/2019 QTP9 Step by Guide Exercises
51/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com
Part 4: Create a Main Calling Test
1. From QuickTest Professional menu bar, select FILE > NEW > TEST to
start a new test.
2. Rename the default ACTION1 as FLTBUSPROCESS.
3. This name is an abbreviation for Flight Business process and this action
is not reusable.
4. In the QUICKTEST PROFESSIONAL window, select the FLTBUSPROCESS
action.
5. From the QuickTest Professional menu bar, select INSERT > CALL TO
COPY OF ACTION. The SELECTACTIONdialog box appears.
6. In the SELECT ACTION dialog box, browse, and select the
LABCH8_1_FLIGHTLOGINtest.
7. IN THE ACTION list, ensure that FLIGHT_LOGIN is selected.
8. Ensure that the AFTER THE CURRENT STEP option is selected.
9. ClickOK. In KEYWORD VIEW, COPY OF FLIGHT_LOGIN appears.
10. In the KEYWORD VIEW, select the FLTBUSPROCESS action.
-
8/8/2019 QTP9 Step by Guide Exercises
52/97
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_NEWORDERtest.
13. In the ACTION list, ensure that FLIGHT_NEWORDERis selected.
14. Ensure that the AFTER THE CURRENT STEP option is selected.
15. In KEYWORD VIEW, COPY OF FLIGHT_NEWORDER appears before the
FLIGHT_LOGIN test.
16. Drag and drop the FLIGHT_LOGIN action before the
FLIGHT_NEWORDERaction.
17. Save the test as LABCH8_4_FLTBUSPROCESS.
18. Close the FLIGHT RESERVATION window and then launch the LOGIN
window of the application. Do not log in.
-
8/8/2019 QTP9 Step by Guide Exercises
53/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com19. Run the test. The test should pass.
20. Close the QuickTest Professional and Flight Reservation
applications.
-
8/8/2019 QTP9 Step by Guide Exercises
54/97
Exercise: Adding Steps Without Recording
Create a test that searches for the LOGIN window. If the window is found, enterthe 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:
Part 1: Operate on the Login window.
Part 2: Add objects to Object Repository.
Part 3: Verify that the Login window exists.
Part 4: Insert a report step.
Part 5: Set the ELSE statement.
Part 1: Operate on the Login Window
1. Open the QuickTest Professional application.
2. From the QuickTest Professional menu bar, select INSERT >
CONDITIONAL STATEMENT> IF ... THEN. The STATEMENTstep is
added in KEYWORD VIEW.
-
8/8/2019 QTP9 Step by Guide Exercises
55/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com3. In KEYWORD VIEW, in the ITEM column, click the STATEMENT step. The
step changes to a list.
4. From the STATEMENT list, select OBJECT FROM REPOSITORY. The
SELECT OBJECT FORSTEP dialog box appears.
5. Leave the SELECT OBJECT FORSTEP dialog box open.
Part 2: Add Objects to Object Repository
1. Open the LOGIN window of the Flight Reservation application.
2. In the SELECT OBJECT FORSTEP 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.
-
8/8/2019 QTP9 Step by Guide Exercises
56/97
4. In the OBJECT SELECTION dialog box, clickOK. This adds the LOGIN
object to the object repository tree in the SELECT OBJECT FORSTEP
dialog box.
5. Repeat steps 3 and 4 for the AGENT NAME and PASSWORD fields, and forthe 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 FORSTEP dialog box.
7. In the object repository tree, select the LOGIN window object.
8. Click OK.
The object is added to the IF statement in KEYWORD VIEW.
Part 3: Verify that the Login Window Exists
1. In KEYWORD VIEW, select the LOGIN object.
2. In the OPERATION column, change the operation from ACTIVATE to
EXIST.
3. From the QuickTest Professional menu bar, select INSERT> NEWSTEP.
A new step is added.
4. From the list, select AGENTNAME.
5. In the VALUE column, type your first name.
-
8/8/2019 QTP9 Step by Guide Exercises
57/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com
6. Repeat the steps from 3 through 5 to add the password. In step 5, set
the password to MERCURY.
7. Repeat the steps 3 and 4 to add the OK button.
8. Save the test as LABCH9_3.
9. Run the test. The test passes.
Part 4: Insert a Report Step
1. In K EYWORD VIEW, select the OKstep.
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.
-
8/8/2019 QTP9 Step by Guide Exercises
58/97
4. In the NAME field, type LOGINWINDOWFOUND.
5. In the DETAILS field, type THEFLIGHTRESERVATION APPLICATION
LOGIN IS SUCCESSFUL.
6. Click OK.
7. Close the Flight Reservation application and open it again but do not
log on.
8. Save the test as LABCH9_4.
9. Run the test.
10. View the test results to see how the REPORTEREVENT reports the test
status.
Part 5: Set the Else Statement
1. Close the Flight Reservation application.
2. Run the test again.
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.
-
8/8/2019 QTP9 Step by Guide Exercises
59/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com
5. In KEYWORD VIEW, select the IF statement.
6. From the QuickTest Professional menu bar, select INSERT
>
CONDITIONAL STATEMENT > ELSE.
7. THE ELSE statement appears at the end of the test. Click the step with the
ELSEstatement. The step changes to a list.
8. From the list, select STEPGENERATOR. The STEP GENERATORdialog
box appears.
9. In the STEP GENERATORdialog box, from the CATEGORY list, select
FUNCTIONS.
10. From the LIBRARY list, select ALL. The ALL function library appears.
11. From the OPERATION list, select INVOKEAPPLICATION.
12. In the ARGUMENTS section, select the COMMAND row.
-
8/8/2019 QTP9 Step by Guide Exercises
60/97
13. In the VALUE column, type the absolute path for the Flight
Reservation application:
C:\PROGRAM FILES\MERCURY INTERACTIVE\QUICKTEST
PROFESSIONAL\SAMPLES\FLIGHT\APP\FLIGHT4A.EXE.
14. ClickOK.
15. Run the test.
16. It takes a few seconds to view the test run.
17. In KEYWORD VIEW, select the last step.
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
FORSTEP dialog box appears.
20. In the SELECT OBJECT FOR STEP dialog box, in the object repository
tree, select the LOGIN window object and clickOK.
21. In the KEYWORD VIEW, select the LOGIN step.
22. FROM THE QUICKTEST PROFESSIONAL menu bar, select INSERT> NEW
STEP. A new step is added.
23. From the list, select AGENTNAME.
-
8/8/2019 QTP9 Step by Guide Exercises
61/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com
24. In the VALUE column, type LAURENCE.
25. From the QuickTest Professional menu bar, select INSERT > NEW
STEP. A new step is added.
26. From the list, select PASSWORD.
27. In the VALUE column, type MERCURY.
28. FROM THE QUICKTEST PROFESSIONAL menu bar, select INSERT> NEW
STEP. A new step is added.
29. From the list, select OK.
30. Close the LOGIN window.
31. Save the test as LABCH9_5.
32. Run the test.
-
8/8/2019 QTP9 Step by Guide Exercises
62/97
33. View the test results.
34. Verify that the ELSE statement was executed.
35. Close the QuickTest Professional and Flight Reservation
applications.
-
8/8/2019 QTP9 Step by Guide Exercises
63/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com
Exercise: Creating a Custom Checkpoint
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:
Part 1: Record a test.
Part 2: Create output parameters to calculate variables.
Part 3: Use a formula in the DATA TABLE.
Part 4: Use a conditional statement to verify the calculation.
Part 5: Report status of the PRICECHKparameter.
Part 6: Set a breakpoint and create a failure.
Part 1: Record a Test
1. Open the QuickTest Professional and Flight Reservation applications.
2. Record a new reservation that includes the following flight
information: DATE OF FLIGHT: 12-12-09
-
8/8/2019 QTP9 Step by Guide Exercises
64/97
FLY FROM: FROM: Frankfurt
FLY TO: TO: London NAME:
NAME: Sam Smith
TICKETS: 2
CLASS: First
3. Save the test as LABCH11_1.
4. Run the test. The test playback should be successful.
-
8/8/2019 QTP9 Step by Guide Exercises
65/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com
Part 2: Create Output Parameters to Calculate Variables
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.
3. Select INSERTOUTPUTVALUE to create an output parameter. The
OBJECT SELECTION - OUTPUT VALUE PROPERTIES dialog box appears.
4. ClickOK. The OUTPUT VALUE PROPERTIES dialog box appears.
5. Check the TEXT check box and clickMODIFY. The OUTPUT OPTIONS
dialog box appears.
6. In the NAME field, type NTICKETS.
7. ClickOKto close the OUTPUT OPTIONS dialog box.
8. Select the AFTER CURRENT STEP option.
9. ClickOKto close the OUTPUT VALUE PROPERTIES dialog box.
10. Verify that:
1) A TICKETS step appears in KEYWORD VIEW that has the
-
8/8/2019 QTP9 Step by Guide Exercises
66/97
OUTPUT value in the OPERATION column.
2) A COLUMN NAMED NTICKETS appears in the GLOBAL sheet of
DATA
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 PARAMETERNAME dialog box
appears.
14. In the DATA TABLE COLUMN NAME field, type PRICECHK.
15. ClickOK. The new column name appears in the DATA TABLE.
16. Save the test as LABCH11_2.
-
8/8/2019 QTP9 Step by Guide Exercises
67/97
For more QTP Realtime Sripts, visit
www.ramupalanki.comPart 3: Use a Formula 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 PRICECHKcolumn, type the following
formula:
=ROUND(A1*B1,2)=ROUND(C1,2)
3. To perform the calculation, pressENTER. The TRUE value
appears in the PRICECHKcolumn.
4. Change the value of NTICKETS to 2 and press ENTER. The FALSE value
appears in the PRICECHKcolumn.
Part 4: Use a Conditional Statement to Verify
the Calculation
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 STEPGENERATORdialog box appears.
3. In the CATEGORY list, select UTILITYOBJECTS.
-
8/8/2019 QTP9 Step by Guide Exercises
68/97
4. In the OBJECT list, select DATATABLE.
5. In the OPERATION list, ensure that VALUE is selected.
6. For the PARAMETERID field, click in the VALUE column and type
PRICECHK.
7. ENSURE THAT THE RETURN VALUE check box is checked.
8. In the RETURN VALUE field, type VPRICECHK.
9. Click OKto insert this step into the test.
10. From the QuickTest Professional menu bar, select INSERT>
CONDITIONAL STATEMENT > IF ... THEN.
-
8/8/2019 QTP9 Step by Guide Exercises
69/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com11. Click the VALUE cell of this step and overwrite TRUE with
VPRICECHK=TRUE.
Part 5: Report Status of the PriceChk Parameter
1. From QuickTest Professional menu bar, select INSERT> REPORT. The
INSERT REPORT dialog box appears.
2. In the STATUS list, select PASSED.
3. In the NAME field, type TOTAL.
4. In the DETAILS field, type TOTAL WAS CALCULATED SUCCESSFULLY.
5. Click OK.
6. In KEYWORD VIEW, select the IF statement.
7. From the QuickTest Professional menu bar, select INSERT>
CONDITIONAL STATEMENT> ELSE. The ELSEstatement line is
highlighted.
8. From the QuickTest Professional menu bar, select INSERT> REPORT.
The INSERT REPORT dialog box appears.
9. In the STATUS list, select FAILED.
-
8/8/2019 QTP9 Step by Guide Exercises
70/97
10. In the NAME field, type TOTAL.
11. In the DETAILS field, type TOTAL WAS NOT CALCULATED
SUCCESSFULLY.
12. ClickOK.
13. Save the test as LABCH11_5.
14. Ensure that the AUT is in the initial condition.
15. Run the test and view the test results.
16. In the TEST RESULTS window, check that the REPORTEREVENT 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.
-
8/8/2019 QTP9 Step by Guide Exercises
71/97
For more QTP Realtime Sripts, visit
www.ramupalanki.comPart 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.
2. From the QuickTest Professional menu bar, select DEBUG>
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.
4. The number of tickets can be 1-10, inclusive of 1 and 10.
5. On the QuickTest Professional toolbar, clickRUN. The test continues to
run from the breakpoint step.
6. Open the TEST RESULTS window. The test fails.
7. Expand all steps in the TEST RESULTS window to view the output of the
REPORTERstep.
8. Check the values in RUN-TIME DATA TABLE to see which values passed.
9. Close the QuickTest Professional and Flight Reservation applications.
-
8/8/2019 QTP9 Step by Guide Exercises
72/97
Exercise: Creating a Database Checkpoint
In this exercise, you create a test to verify that an order number generated in theFlight 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.
This exercise consists of the following parts:
Part 1: Create output parameters for order number and tickets.
Part 2: Use Microsoft Query to query the ORDERS table.
Part 3: Set database checkpoint properties for an order number.
Part 4: Set database checkpoint properties for the number of tickets.
Part 5: Run the test and view results.
Part 1: Create Output Parameters for Order Number
and Tickets
1. Open the QuickTest Professional application.
2. Do not select any add-ins.
3. On the QuickTest Professional toolbar, clickNEW.
-
8/8/2019 QTP9 Step by Guide Exercises
73/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com
4. Open and log on to the Flight Reservation application.
5. Record a new reservation that includes the following flightinformation (be sure you are in Record mode)
DATE OF FLIGHT: 12-12-09
FLY FROM: Frankfurt
FLY TO: London
NAME: Sam Smith
TICKETS: 2
CLASS: First
6. ClickINSERTORDER.
-
8/8/2019 QTP9 Step by Guide Exercises
74/97
7. From the QuickTest Professional menu bar, select INSERT
SYNCHRONIZATION POINTafter the progress bar completes. The
cursorchanges to a pointed finger.
8. In the FLIGHT RESERVATION window, in the progress bar, clickthe words INSERTDONE... with the pointed finger cursor.
9. In the OBJECT SELECTION - SYNCHRONIZATION POINT dialog box,
click
OK. The ADDSYNCHRONIZATIONPOINTdialog box appears.
10. From the PROPERTY NAME list, select TEXT.
11. In the PROPERTY VALUE field, type "INSERTDONE...".
12. In the TIMEOUT field, retain the default value.
13. ClickOK.
14. In the FLIGHT RESERVATION window, click the NEW ORDER
button to set end conditions for the test.
15. On the QuickTest Professional toolbar, clickSTOP to stop the test.
16. Save the test as LABCH12_1.
17. In KEYWORD VIEW, select the INSERTDONE step.
18. In ACTIVE SCREEN, right-click the ORDERNO field, and select
-
8/8/2019 QTP9 Step by Guide Exercises
75/97
For more QTP Realtime Sripts, visit
www.ramupalanki.comINSERTOUTPUT VALUEto create an output parameter. The OBJECT
SELECTION-OUTPUT VALUE PROPERTIES dialog box appears.
19. ClickOK. The OUTPUT VALUE PROPERTIES dialog box appears.
20. Check the TEXT check box, and click MODIFY. The OUTPUT
OPTIONS dialog box appears.
21. In the NAME field, type GUIORDER_NO.
22. ClickOKto close the OUTPUT OPTIONS dialog box.
23. In the OUTPUT VALUE PROPERTIES dialog box, select the AFTER
CURRENT STEP option.
24. ClickOKto close the OUTPUT VALUE PROPERTIES dialog box.
25. Verify that:
26. The KEYWORD VIEW has an ORDER NO step that has the OUTPUT
value in the OPERATION column.
-
8/8/2019 QTP9 Step by Guide Exercises
76/97
27. The GLOBAL sheet of DATA TABLE has a column named
GUIORDER_NO.
28. Repeat steps 17 to 24 to create an output parameter for the number of
tickets and name it as NTICKETS.
29. Save the test.
30. Run the test to verify that the new order number and the number
of tickets are captured in RUN-TIME DATA TABLE.
Part 2: Use Microsoft Query to Query the Orders Table
1. In KEYWORD VIEW, select the TICKETS step that has the value OUTPUT
in the OPERATION column.
2. From the QuickTest Professional menu bar, select INSERT
CHECKPOINT DATABASE CHECKPOINT. The DATABASEQUERY
WIZARD appears.
3. In the QUERY DEFINITION section, ensure that the CREATE QUERY USING
MICROSOFT QUERYoption is selected.
4. Check the MAXIMUM NUMBER OF ROWS check box.
5. Set MAXIMUM NUMBER OF ROWS to 5.
6. Ensure that the SHOW ME HOW TO USEMICROSOFTQUERY check box
-
8/8/2019 QTP9 Step by Guide Exercises
77/97
For more QTP Realtime Sripts, visit
www.ramupalanki.comis checked, and clickNEXT.
7. In the INSTRUCTIONS FORMICROSOFTQUERY dialog box, clickOK.
8. In the CHOOSEDATA SOURCE dialog box, in the DATABASES list, click
QT_FLIGHT32*.
9. The Flight Reservation AUT uses the QT_FLIGHT32* database.
10. Ensure that the USE THE QUERY WIZARD TO CREATE/EDIT QUERIES check
box is checked.
11. ClickOK.
12. In the QUERY WIZARD - CHOOSE COLUMNS dialog box, in the AVAILABLE
TABLES AND COLUMNS list, double-click the ORDERS table to display allcolumns of the table.
13. From the AVAILABLE TABLES AND COLUMNS list, select the columns
ORDER_NUMBER, TICKETS_ORDERED, and AGENTS_NAME, and use
-
8/8/2019 QTP9 Step by Guide Exercises
78/97
the right arrow button to add each column to the COLUMNS IN YOUR
QUERY list. ClickNEXT.
14. In the QUERY WIZARD - FILTERDATA dialog box, clickNEXT.
15. In the QUERY WIZARD - SORT ORDERdialog box, from the SORT BY list,
select ORDER_NUMBER.
16. Select the DESCENDING option, and clickNEXT.
17. In the QUERY WIZARD - FINISH dialog box, clickSAVEQUERY.
18. In the SAVE AS dialog box, clickSAVE 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.
20. ClickFINISH. The DATABASE CHECKPOINT PROPERTIES dialog box
displays a table that shows the result set of the SQL query.
Part 3: Set Database Checkpoint Properties for an
Order Number
1. In the DATABASE CHECKPOINT PROPERTIES dialog box, click the upper
left corner to select all rows in the result set.
-
8/8/2019 QTP9 Step by Guide Exercises
79/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com2. Click the REMOVE FROMCHECKbutton to uncheck all rows currently
selected.
3. Click the first cell of the ORDER_NUMBERcolumn.
4. Click the ADD TOCHECKbutton to select the first cell of the
ORDER_NUMBERcolumn.
5. In the CONFIGURE VALUE section, select the PARAMETERoption, and
click the PARAMETEROPTIONS button.
6. In the PARAMETEROPTIONS dialog box, from the NAME list, select
GUI_ORDER_NOand clickOK.
7. In the DATABASE CHECKPOINT PROPERTIES dialog box, select the AFTER
CURRENT STEP option.
-
8/8/2019 QTP9 Step by Guide Exercises
80/97
Part 4: Set Database Checkpoint Properties for
the Number of Tickets
1. Click the first cell of the TICKETS column.
2. Click the ADD TOCHECKbutton to select the first cell of the TICKETS
column.
3. In the CONFIGURE VALUE section, select the PARAMETERoption, and
click the PARAMETEROPTIONS button.
4. In the PARAMETEROPTIONS dialog box, from the NAME list, select
NTICKETSand clickOKto close the PARAMETEROPTIONSdialog box.
5. ClickOKto close the DATABASE CHECKPOINT PROPERTIES dialog box.
6. Save the test as LABCH12_4.
Part 5: Run the Test and View Results
1. Run the test. The test should succeed.
2. On the QuickTest Professional toolbar, click the RESULTS button to view
the test results. The TEST RESULTS window appears. The test should
pass.
3. Close the QuickTest Professional and Flight Reservation applications.
-
8/8/2019 QTP9 Step by Guide Exercises
81/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com
Exercise: Creating a Database Checkpoint
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.
This exercise consists of the following parts:
Part 1: Create output parameters for order number and tickets.
Part 2: Use Microsoft Query to query the ORDERS table.
Part 3: Set database checkpoint properties for an order number.
Part 4: Set database checkpoint properties for the number of tickets.
Part 5: Run the test and view results.
Part 1: Create Output Parameters for Order Number
and Tickets
1. Open the QuickTest Professional application.
2. Do not select any add-ins.
3. On the QuickTest Professional toolbar, clickNEW.
-
8/8/2019 QTP9 Step by Guide Exercises
82/97
4. Open and log on to the Flight Reservation application.
5. Record a new reservation that includes the following flightinformation (be sure you are in Record mode)
DATE OF FLIGHT: 12-12-09
FLY FROM: Frankfurt
FLY TO: London
NAME: Sam Smith
TICKETS: 2
CLASS: First
6. ClickINSERTORDER.
-
8/8/2019 QTP9 Step by Guide Exercises
83/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com7. From the QuickTest Professional menu bar, select INSERT
SYNCHRONIZATION POINTafter the progress bar completes. The
cursorchanges to a pointed finger.
8. In the FLIGHT RESERVATION window, in the progress bar, click
the words INSERTDONE... with the pointed finger cursor.
9. In the OBJECT SELECTION - SYNCHRONIZATION POINT dialog box,
click
OK. The ADDSYNCHRONIZATIONPOINTdialog box appears.
10. From the PROPERTY NAME list, select TEXT.
11. In the PROPERTY VALUE field, type "INSERTDONE...".
12. In the TIMEOUT field, retain the default value.
13. ClickOK.
14. In the FLIGHT RESERVATION window, click the NEW ORDER
button to set end conditions for the test.
15. On the QuickTest Professional toolbar, clickSTOP to stop the test.
16. Save the test as LABCH12_1.
17. In KEYWORD VIEW, select the INSERTDONE step.
18. In ACTIVE SCREEN, right-click the ORDERNO field, and select
-
8/8/2019 QTP9 Step by Guide Exercises
84/97
INSERTOUTPUT VALUEto create an output parameter. The OBJECT
SELECTION-OUTPUT VALUE PROPERTIES dialog box appears.
19. ClickOK. The OUTPUT VALUE PROPERTIES dialog box appears.
20. Check the TEXT check box, and click MODIFY. The OUTPUT
OPTIONS dialog box appears.
21. In the NAME field, type GUIORDER_NO.
22. ClickOKto close the OUTPUT OPTIONS dialog box.
23. In the OUTPUT VALUE PROPERTIES dialog box, select the AFTER
CURRENT STEP option.
24. ClickOKto close the OUTPUT VALUE PROPERTIES dialog box.
25. Verify that:
26. The KEYWORD VIEW has an ORDER NO step that has the OUTPUT
value in the OPERATION column.
-
8/8/2019 QTP9 Step by Guide Exercises
85/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com27. The GLOBAL sheet of DATA TABLE has a column named
GUIORDER_NO.
28. Repeat steps 17 to 24 to create an output parameter for the number of
tickets and name it as NTICKETS.
29. Save the test.
30. Run the test to verify that the new order number and the number
of tickets are captured in RUN-TIME DATA TABLE.
Part 2: Use Microsoft Query to Query the Orders Table
1. In KEYWORD VIEW, select the TICKETS step that has the value OUTPUT
in the OPERATION column.
2. From the QuickTest Professional menu bar, select INSERT
CHECKPOINT DATABASE CHECKPOINT. The DATABASEQUERY
WIZARD appears.
3. In the QUERY DEFINITION section, ensure that the CREATE QUERY USING
MICROSOFT QUERYoption is selected.
4. Check the MAXIMUM NUMBER OF ROWS check box.
5. Set MAXIMUM NUMBER OF ROWS to 5.
6. Ensure that the SHOW ME HOW TO USEMICROSOFTQUERY check box
-
8/8/2019 QTP9 Step by Guide Exercises
86/97
is checked, and clickNEXT.
7. In the INSTRUCTIONS FORMICROSOFTQUERY dialog box, clickOK.
8. In the CHOOSEDATA SOURCE dialog box, in the DATABASES list, click
QT_FLIGHT32*.
9. The Flight Reservation AUT uses the QT_FLIGHT32* database.
10. Ensure that the USE THE QUERY WIZARD TO CREATE/EDIT QUERIES check
box is checked.
11. ClickOK.
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
ORDER_NUMBER, TICKETS_ORDERED, and AGENTS_NAME, and use
-
8/8/2019 QTP9 Step by Guide Exercises
87/97
For more QTP Realtime Sripts, visit
www.ramupalanki.comthe right arrow button to add each column to the COLUMNS IN YOUR
QUERY list. ClickNEXT.
14. In the QUERY WIZARD - FILTERDATA dialog box, clickNEXT.
15. In the QUERY WIZARD - SORT ORDERdialog box, from the SORT BY list,
select ORDER_NUMBER.
16. Select the DESCENDING option, and clickNEXT.
17. In the QUERY WIZARD - FINISH dialog box, clickSAVEQUERY.
18. In the SAVE AS dialog box, clickSAVE 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.
20. ClickFINISH. The DATABASE CHECKPOINT PROPERTIES dialog box
displays a table that shows the result set of the SQL query.
Part 3: Set Database Checkpoint Properties for an
Order Number
1. In the DATABASE CHECKPOINT PROPERTIES dialog box, click the upper
left corner to select all rows in the result set.
-
8/8/2019 QTP9 Step by Guide Exercises
88/97
2. Click the REMOVE FROMCHECKbutton to uncheck all rows currently
selected.
3. Click the first cell of the ORDER_NUMBERcolumn.
4. Click the ADD TOCHECKbutton to select the first cell of the
ORDER_NUMBERcolumn.
5. In the CONFIGURE VALUE section, select the PARAMETERoption, and
click the PARAMETEROPTIONS button.
6. In the PARAMETEROPTIONS dialog box, from the NAME list, select
GUI_ORDER_NOand clickOK.
7. In the DATABASE CHECKPOINT PROPERTIES dialog box, select the AFTER
CURRENT STEP option.
-
8/8/2019 QTP9 Step by Guide Exercises
89/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com
Part 4: Set Database Checkpoint Properties for
the Number of Tickets
1. Click the first cell of the TICKETS column.
2. Click the ADD TOCHECKbutton to select the first cell of the TICKETS
column.
3. In the CONFIGURE VALUE section, select the PARAMETERoption, and
click the PARAMETEROPTIONS button.
4. In the PARAMETEROPTIONS dialog box, from the NAME list, select
NTICKETSand clickOKto close the PARAMETEROPTIONSdialog box.
5. ClickOKto close the DATABASE CHECKPOINT PROPERTIES dialog box.
6. Save the test as LABCH12_4.
Part 5: Run the Test and View Results
1. Run the test. The test should succeed.
2. On the QuickTest Professional toolbar, click the RESULTS button to view
the test results. The TEST RESULTS window appears. The test shouldpass.
3. Close the QuickTest Professional and Flight Reservation applications.
-
8/8/2019 QTP9 Step by Guide Exercises
90/97
Exercise: Creating a Recovery Scenario
In this exercise, you will create a test that encounters an error during playback. Youwill then create a recovery scenario to correct the problem when the automated test
runs.
Part 1: Create a Basic Test by Addding a Step Without Recording
Part 2: Set a Synchronization Point
Part 3: Set a Parameter
Part 4: Create a Recovery Scenario
Part 5: Change Recovery Scenario Run Settings
Part 1: Add a Step Without Recording
1. Create a Blank Test.
2. From the QuickTest Professional menu bar, select INSERT > NEW STEP>
STEP
GENERATOR
.
3. The STEP GENERATORdialog box appears.
4. Insert the following:
-
8/8/2019 QTP9 Step by Guide Exercises
91/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com
a. CATEGORY: Functions
b. LIBRARY: All
c. OPERATION: InvokeApplication
d. ARGUMENTS: COMMAND - Value
C:\Program Files\Mercury Interactive\QuickTest
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.
7. Leave the Login window up on desktop.
8. Save this test as RECOVERY_SCENARIO.
Part 2: Set a Synchronization Point
-
8/8/2019 QTP9 Step by Guide Exercises
92/97
1. Ensure that the Login window is on desktop.
2. Click on the RECORD button to record the login business process.
3. Accept the recording on Any open Windows-based application
selection.
4. Log into the application with:
a. AGENT NAME: 1234
b. PASSWORD: mercury
5. The Flight application is in the process of starting. Because it takes
a while, we will synchronize on the window.
6. While still in Record mode, from the menu bar choose INSERT>
SYNCHRONIZATION POINT
7. Choose the Flights window object to synchronize on.
8. In the Properties dialog, choose Enabled True for the state of
the window.
9. Continue recording the closing of the main Flight application window
as the final step of the test.
10. Stop recording.
-
8/8/2019 QTP9 Step by Guide Exercises
93/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com11. Run the test to verify that it functions as expected:
a. Flight application invokes
b. Login window appears and in logged into.
c. Flight application closes.
Part 3: Set a Parameter
1. Parameterize the password entry in the test to run multiple iterations.
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.
4. Create a parameter named "Password.
-
8/8/2019 QTP9 Step by Guide Exercises
94/97
5. Replace the original encrypted Set Secure string with a Set operation and
the understandable password "mercury".
6. Create a second row under Password with an incorrect password value
of "merc".
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.
8. Stop the test, but leave the error message on desktop.
Part 4: Create a Recovery Scenario
1. From the menu bar choose RESOURCES> SCENARIOMANAGER
2. Click on the New Scenario button.
3. Click the NEXT button.
4. Define the Trigger Event as a Pop-up Window.
5. Click the NEXT button.
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.
-
8/8/2019 QTP9 Step by Guide Exercises
95/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com7. Click the NEXT button.
8. Click the NEXT button again.
9. In the Recovery Operation dialog, set the operation as
Keyboard /Mouse operation.
10. Click the NEXT button.
11. Choose the option Button with specified label.
12. Click on pointing hand, then click on the OK button in the error
message dialog.
13. Define another Recovery Operation to kill the Flight4a application
process.
14. Choose Close application process.
15. Choose the flight4a.exe process from the list on left.
-
8/8/2019 QTP9 Step by Guide Exercises
96/97
16. Click the ADD button to move the process from left to right.
17. Click the NEXT button.
18. You are now back in the Recovery Operations window and the
two operations should be listed.
19. Uncheck the Add another box.
20. Click the NEXT button.
21. You are in the Post-Recovery Test Run options window.
22. Choose Proceed to next test iteration.
23. Save the test as Incorrect Password Error
24. ClickFINISH.
25. ClickCLOSE.
26. Add this recovery scenario to the current test.
27. Run the test to ensure that it works as expected. You will notice that the
test hangs.
Part 5: Change Recovery Scenario Run Settings
-
8/8/2019 QTP9 Step by Guide Exercises
97/97
For more QTP Realtime Sripts, visit
www.ramupalanki.com
1. Go to the menu bar and select FILE > TESTSETTINGS.
2. Click on the RECOVERY tab.
3. Change the Run settings to Run on every step.
4. Re-run the test.
5. View Test Results for information about the recovery scenario usage.