qtp lab exercises

52
Exercise: 1. 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. Part 1: Launch QuickTest Professional 9.0. Part 2: Set QuickTest test options. Part 1: Launch QuickTest Professional 1. Click START PROGRAMS QUICKTEST PROFESSIONAL QUICKTEST PROFESSIONAL. 2. Ensure all options are unchecked in the ADD-IN MANAGER dialog box. 3. Click OK. 4. In the QUICKTEST PROFESSIONAL window, click BLANK TEST. Part 2: Set QuickTest Test Options 1. From the QuickTest Professional menu bar, select TOOLS OPTIONS. 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. 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 OTHER MERCURY 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.

Upload: santhi-sudha

Post on 21-Apr-2015

576 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: QTP Lab Exercises

Exercise: 1. 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. Part 1: Launch QuickTest Professional 9.0. Part 2: Set QuickTest test options. Part 1: Launch QuickTest Professional 1. Click START → PROGRAMS → QUICKTEST PROFESSIONAL → QUICKTEST

PROFESSIONAL. 2. Ensure all options are unchecked in the ADD-IN MANAGER dialog box. 3. Click OK. 4. In the QUICKTEST PROFESSIONAL window, click BLANK TEST. Part 2: Set QuickTest Test Options 1. From the QuickTest Professional menu bar, select TOOLS → OPTIONS. 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. 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 OTHER MERCURY 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.

Page 2: QTP Lab Exercises

Exercise: 2. Creating a Basic Test 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: 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 3. Click OK. The FLIGHT RESERVATION window appears. 4. From the QuickTest Professional menu bar, select FILE → NEW → TEST. 5. On the QuickTest Professional toolbar, click RECORD. The RECORD AND RUN

SETTINGS dialog box appears. Note: Start and end recording from the FLIGHT RESERVATION window to set the window as the initial and end condition for the test. 6. Select the RECORD AND RUN TEST ON ANY OPEN WINDOWS-BASED APPLICATION

option. 7. Click OK. 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.

Note: 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.

Page 3: QTP Lab Exercises

Part 2: Record the Business Process 1. Click the FLIGHT RESERVATION window to activate it. 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. 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, click OK. 6. Specify the following: – NAME: SAM SMITH

– 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. 9. On the QuickTest Professional toolbar, click STOP to stop the test. Part 3: Save the Test 1. In the QUICKTEST PROFESSIONAL window, select FILE→ SAVE. The SAVE TEST

dialog box appears. 2. Browse to the directory \QTP90USING\TESTS. 3. In the FILE NAME field, type LABCH3_3. 4. Click SAVE. Note: 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.

Page 4: QTP Lab Exercises

Part 4: Run the Test 1. On the toolbar, click RUN. 2. Click OK to 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. 2. From the tree on the left side of TEST RESULTS window, right-click the TEST <TEST> SUMMARY node and select EXPAND ALL. 3. View the results. 4. Close the TEST RESULTS window and QuickTest Professional.

Page 5: QTP Lab Exercises

Exercise: 3. Using Object Repository 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: 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 Note: Ensure that the QuickTest Professional and Flight Reservation applications are open on your computer. 1. In the QuickTest Professional menu bar, select FILE → NEW → TEST. 2. Click RECORD. The RECORD AND RUN SETTINGS dialog box appears. 3. In the RECORD AND RUN SETTINGS dialog box, click OK. 4. In the FLIGHT RESERVATION window toolbar, click NEW ORDER button to set the initial condition. 5. Enter the following flight data: – DATE OF FLIGHT: 12-12-09

– FLY FROM: Frankfurt

– FLY TO: London

6. Click FLIGHTS. The FLIGHTS TABLE appears. 7. Click OK to accept the default choice. 8. Enter the following purchase data: – NAME: Maura

– TICKETS: 2

– CLASS: First

Page 6: QTP Lab Exercises

9. Click INSERT ORDER. 10. On the FLIGHT RESERVATION window toolbar, click NEW ORDER to set end conditions. 11. On the QuickTest Professional toolbar, click STOP to end the recording session. 12. Save the test as LABCH4_1. Part 2: Open the Object Repository Dialog Box 1. From the QuickTest Professional menu bar, select RESOURCES → OBJECT

REPOSITORY. 2. How many objects can you identify in the Object Repository? 3. How many different classes of objects can you identify? 4. How many objects of the class WinButton are shown? 5. 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. 2. In the OBJECT REPOSITORY tree, right-click the BUTTON object. 3. From the menu, select RENAME. 4. Type the new name as NEW ORDER. 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.

Page 7: QTP Lab Exercises

2. On the QuickTest Professional toolbar, click the OBJECT SPY 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 properties for the NAME field. 5. Document the following object property values: a) CLASS NAME ______________________ b) ENABLED ______________________ c) ATTACHED TEXT _____________________ d) NATIVECLASS ______________________ 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 OBJECT REPOSITORY dialog box appears. 3. In the OBJECT REPOSITORY tree, select the NEW ORDER object. 4. Click the HIGHLIGHT IN APPLICATION button. 5. Observe the FLIGHTS RESERVATION window. 6. What did you observe? Part 6: Use the Locate in Repository Feature 1. On the OBJECT REPOSITORY toolbar, click the LOCATE IN REPOSITORY button. The cursor changes to a pointing hand. 2. In the FLIGHTS RESERVATION window, use the pointing hand cursor to point to the NEW ORDER button and click the NEW ORDER button. The SELECT AN OBJECT

dialog box appears. 3. Click OK.

Page 8: QTP Lab Exercises

4. What did you observe? Part 7: Add a New Object 1. In the OBJECT REPOSITORY tree, select the FLIGHT object. 2. On the Object Repository toolbar, click the DEFINE NEW TEST OBJECT button. The DEFINE NEW TEST OBJECT dialog box appears. Note: Alternatively, select OBJECT → DEFINE NEW TEST OBJECT.

3. From the ENVIRONMENT list, select STANDARD WINDOWS. 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 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. 9. Close the OBJECT REPOSITORY dialog box. 10. Save the test as LABCH4_7.

11. Close the QuickTest Professional and Flight Reservation application

Page 9: QTP Lab Exercises

Exercise: 4. 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. 6. Click OK. 7. On the QuickTest Professional toolbar, click RECORD. 8. In the RECORD AND RUN SETTINGS dialog box, click OK. 9. On the Flight Reservation toolbar, click the NEW ORDER icon 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. 12. Click OK to accept the default choice.

Page 10: QTP Lab Exercises

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, click NEW ORDER to set end conditions. 17. On the QuickTest Professional toolbar, click STOP to stop recording. 18. Save the test as LABCH5_1. Part 2: Run the Modified Test 1. On the QuickTest Professional toolbar, click RUN. 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. 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 INSERT ORDER step. 3. On the QuickTest Professional toolbar, click RECORD. 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.

Page 11: QTP Lab Exercises

Exercise: 5. 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. 2. Ensure that the FLIGHT RESERVATION window is open. 3. On the QuickTest Professional toolbar, click RECORD. The RECORD AND RUN

SETTINGS dialog box appears. 4. Click OK to close the he RECORD AND RUN SETTINGS dialog box. 5. In the FLIGHT RESERVATION window, click the NEW ORDER button 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, click OK to accept the default choice. 9. Enter the following information: – NAME: Sam Smith

– TICKETS: 2

Page 12: QTP Lab Exercises

– 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 INSERT

DONE... 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 CHECKPOINT PROPERTIES dialog box appears. 14. In the CHECKPOINT PROPERTIES dialog box, check the TEXT property and uncheck all other properties. 15. Click OK. 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. 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, 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. 4. Close the TEST RESULTS window. Part 3: Modify the Test 1. In KEYWORD VIEW, select the last BUTTON step that appears. Note: In ACTIVE SCREEN, the ORDER NO: field must show the number generated after

Page 13: QTP Lab Exercises

the insert done operation. 2. 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. 3. In the OBJECT SELECTION - CHECKPOINT PROPERTIES dialog box, click OK. 4. In the CHECKPOINT PROPERTIES dialog box, uncheck all the check boxes except TEXT. Note: Ensure that when you select the TEXT property, the ORDER NO appears in the CONSTANT field. 5. Click OK. 6. Save the test as LABCH6_3. 7. On the QuickTest Professional toolbar, click RUN to run the test. The test should fail. 8. View the test results. Part 3(a): Add a Regular Expression 1. In QUICKTEST PROFESSIONAL window, in KEYWORD VIEW, select the ORDER NO

step. 2. In the ORDER NO row, select the VALUE column. The CHECKPOINT PROPERTIES

button appears. 3. Click the CHECKPOINT PROPERTIES button. The CHECKPOINT PROPERTIES dialog box appears. 4. Click the CONSTANT VALUE OPTIONS button beside the CONSTANT field. The CONSTANT VALUE OPTIONS dialog box appears. 5. In the CONSTANT VALUE OPTIONS dialog box, click the REGULAR EXPRESSION

check box. 6. Type [0-9]+ in the VALUE field and click OK. 7. In the CHECKPOINT PROPERTIES dialog box, click OK. 8. Save test as LABCH6_3_A.

Page 14: QTP Lab Exercises

9. On the QuickTest Professional toolbar, click RUN 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. Click RECORD. The RECORD AND RUN SETTINGS dialog box appears. 3. In the RECORD AND RUN SETTINGS dialog box, click OK. 4. In the FLIGHT RESERVATION window, click the NEW ORDER button to set the initial conditions. 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. 7. In the ORDER NO. field, type 3. 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. 12. In the CHECKPOINT PROPERTIES dialog box, click OK. 13. In the FAX ORDER NO. 3 window, click CANCEL. 14. In the FLIGHT RESERVATION window, click the NEW ORDER button to set end conditions. 15. Stop recording. Part 5: Add a Comment 1. Maximize the QUICKTEST PROFESSIONAL window.

Page 15: QTP Lab Exercises

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 ORDER NO. step. 5. Click the COMMENT column. Type A UNIQUE ORDER IS GENERATED EVERY TIME

YOU INSERT AN ORDER. in the COMMENT column. 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, click OK. 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. 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. Part 8: Fix the Test 1. On the QuickTest Professional toolbar, select RESOURCES → OBJECT

REPOSITORY. The OBJECT REPOSITORY dialog box appears. 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

Page 16: QTP Lab Exercises

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 REGULAR EXPRESSION check box. A dialog box appears. 8. In the dialog box, click NO. 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.

Page 17: QTP Lab Exercises

Exercise: 6. Using Parameters This exercise requires you to add a checkpoint, a synchronization point, and regular 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 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 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 → TEST. 4. On the QuickTest Professional toolbar, click the RECORD button. 5. In the RECORD AND RUN SETTINGS dialog box, click OK. 6. Click the FLIGHT RESERVATION window to activate it. 7. In the FLIGHT RESERVATION window, click the NEW ORDER button to set initial conditions. 8. Specify the following flight data: – DATE OF FLIGHT: 12-12-09

– FLY FROM: Frankfurt

– FLY TO: London

9. Click the FLIGHTS button. The FLIGHTS TABLE window appears. 10. In the FLIGHTS TABLE window, click OK. 11. Specify the following transaction data: – NAME: Jane Jenkins

– TICKETS: 2

Page 18: QTP Lab Exercises

– 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: a) From the QuickTest Professional menu bar, select INSERT → SYNCHRONIZATION POINT after the progress bar completes. The cursor changes to a pointed finger. b) 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. c) In the OBJECT SELECTION - SYNCHRONIZATION POINT dialog box, click OK. The ADD SYNCHRONIZATION POINT dialog box appears. d) From the PROPERTY NAME list, select TEXT. e) In the PROPERTY VALUE field, type "INSERT DONE...". f) Retain the default timeout of 10000 milliseconds. g) Click OK. An INSERT DONE (Wait Property) step is added in KEYWORD VIEW. 15. Add a standard checkpoint that uses a regular expression on the FAX ORDER NO. window title bar. To do this: a) From the Flight Reservation menu bar, select FILE → FAX ORDER. The FAX

ORDER NO. window appears. b) From the QuickTest Professional menu bar, select INSERT → CHECKPOINT → STANDARD CHECKPOINT. The cursor changes to a pointing hand. c) Click the FAX ORDER NO. window title bar with the pointing hand cursor. The OBJECT SELECTION - CHECKPOINT PROPERTIES dialog box appears. d) In the OBJECT SELECTION - CHECKPOINT PROPERTIES dialog box, click OK. The CHECKPOINT PROPERTIES dialog box appears. e) In the CHECKPOINT PROPERTIES dialog box, check the TEXT check box. Uncheck all other check boxes. f) Select the TEXT property and ensure that the CONSTANT option is selected. g) Click the CONSTANT VALUE OPTIONS button next to the CONSTANT field. The CONSTANT VALUE OPTIONS dialog box appears. h) In the VALUE field, replace the existing text with FAX ORDER NO..*. i) Check the REGULAR EXPRESSION check box. j) In the dialog box that appears, click NO. k) Click OK. l) In the CHECKPOINT PROPERTIES dialog box, click OK. m) In the FAX ORDER NO. window, in the FAX NUMBER field, type 4255550150 and click SEND. n) In the FLIGHT RESERVATION window, click the NEW ORDER button to set the end condition.

Page 19: QTP Lab Exercises

o) On the QuickTest Professional toolbar, click STOP. 16. Modify the object properties for the FAX ORDER NO. title bar step to use the regular expression. To do this: a) From the QuickTest Professional menu bar, select RESOURCES → OBJECT

REPOSITORY. The OBJECT REPOSITORY dialog box appears. b) In the OBJECT REPOSITORY dialog box, select the FAX ORDER NO. object. c) In the OBJECT PROPERTIES pane, select the TEXT property row. d) Click the VALUE column. The CONFIGURE THE VALUE button appears. e) Click the CONFIGURE THE VALUE button. The VALUE CONFIGURATION

OPTIONS dialog box appears. f) Ensure that the CONSTANT option is selected. g) In the CONSTANT field, replace the existing text with FAX ORDER NO..*. h) Check the REGULAR EXPRESSION check box. i) In the dialog box that appears, click NO. j) In the VALUE CONFIGURATION OPTIONS dialog box, click OK. k) Close the OBJECT REPOSITORY dialog box. 17. Save the test as LABCH7_1. 18. Run the test. 19. 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 INSERT DONE. 2. From ACTIVE SCREEN, right-click the ORDER NO. field and select INSERT OUTPUT

VALUE. 3. In the OBJECT SELECTION - OUTPUT VALUE PROPERTIES dialog box, click OK. 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.

Page 20: QTP Lab Exercises

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 PARAMETER option. 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, click OK on 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. Note: Select the TICKETS step where operation is SET. This is the second TICKETS step. 3. 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.

Page 21: QTP Lab Exercises

5. In the VALUE CONFIGURATION OPTIONS dialog box, change the parameter type from DATATABLE to RANDOM NUMBER. 6. Change the NUMERIC RANGE from 0 to 100 to 1 to 10. 7. Check the NAME check box and in the NAME field, type TICKETS_OUT. 8. Ensure that the FOR EACH ACTION ITERATION option is selected. 9. Click OK. 10. Save the test as LABCH7_4. 11. Run the test. 12. 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.

13. Close the QuickTest Professional and Flight Reservation applications.

Page 22: QTP Lab Exercises

Exercise: 7. 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. 3. From the QuickTest Professional menu bar, select FILE → NEW → TEST to open a new test. 4. On the QuickTest Professional toolbar, click RECORD. The RECORD AND RUN

SETTINGS dialog box appears. 5. Click OK. 6. In the LOGIN dialog box, type the following information: – AGENT NAME: Alex

– PASSWORD: mercury

7. Click OK. The FLIGHT RESERVATION window appears. 8. On the QuickTest Professional toolbar, click STOP to stop the test. 9. Save the test as LABCH8_1_FLIGHTLOGIN. 10. Close the FLIGHT RESERVATION window. 11. Select START → PROGRAMS → QUICKTEST PROFESSIONAL → SAMPLE

APPLICATIONS → FLIGHT. The LOGIN dialog box appears. 12. Run the test and verify that the test passes. Part 2: Change the Default Name of the Action

Page 23: QTP Lab Exercises

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 the NAME field, replace ACTION1 with FLIGHT_LOGIN. 4. Check the REUSABLE ACTION check box. 5. Click OK. The HINT dialog box appears. 6. In the HINT dialog box, click OK. 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 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 the NAME 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, click OK. 9. Save the test as LABCH8_3_NEWORDER. Part 4: Create a Main Calling Test 1. From QuickTest Professional menu bar, select FILE → NEW → TEST to start a new test.

Page 24: QTP Lab Exercises

2. Rename the default ACTION1 as FLTBUSPROCESS. Note: This name is an abbreviation for Flight Business process and this action is not reusable. 3. In the QUICKTEST PROFESSIONAL window, select the FLTBUSPROCESS action. 4. From the QuickTest Professional menu bar, select INSERT → CALL TO COPY OF

ACTION. The SELECT ACTION dialog box appears. 5. In the SELECT ACTION dialog box, browse, and select the LABCH8_1_FLIGHTLOGIN test. 6. In the ACTION list, ensure that FLIGHT_LOGIN is selected. 7. Ensure that the AFTER THE CURRENT STEP option is selected. 8. Click OK. In KEYWORD VIEW, COPY OF FLIGHT_LOGIN appears. 9. In the KEYWORD VIEW, select the FLTBUSPROCESS action. 10. From the QuickTest Professional menu bar, select INSERT → CALL TO COPY OF

ACTION. 11. In the SELECT ACTION dialog box, from the FROM TEST list, browse and select the LABCH8_3_NEWORDER test. 12. In the ACTION list, ensure that FLIGHT_NEWORDER is selected. 13. Ensure that the AFTER THE CURRENT STEP option is selected. Note: In KEYWORD VIEW, COPY OF FLIGHT_NEWORDER appears before the FLIGHT_LOGIN test. 14. Drag and drop the FLIGHT_LOGIN action before the FLIGHT_NEWORDER action. 15. Save the test as LABCH8_4_FLTBUSPROCESS. 16. Close the FLIGHT RESERVATION window and then launch the LOGIN window of the application. 17. Run the test. The test should pass. 18. Close the QuickTest Professional and Flight Reservation applications.

Page 25: QTP Lab Exercises

Exercise: 8. Adding Steps Without Recording 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: 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 STATEMENT step is added in KEYWORD VIEW. 3. 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

FOR STEP dialog box appears. Note: Leave the SELECT OBJECT FOR STEP 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 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.

Page 26: QTP Lab Exercises

Note: Verify that all of the objects that you have added appear in the object repository tree in the SELECT OBJECT FOR STEP dialog box. 6. In the object repository tree, select the LOGIN window object. 7. 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 → NEW STEP. A new step is added. 4. From the list, select AGENT NAME. 5. In the VALUE column, type your first name. 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 KEYWORD VIEW, select the OK step. 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.

Page 27: QTP Lab Exercises

5. In the DETAILS field, type THE FLIGHT RESERVATION 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. Note: View the test results to see how the REPORTER EVENT 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. Note: You must prepare for the case when the LOGIN window is not found. You can use the ELSE statement to handle this situation. 4. In KEYWORD VIEW, select the IF statement. 5. From the QuickTest Professional menu bar, select INSERT → CONDITIONAL

STATEMENT → ELSE. 6. The ELSE statement appears at the end of the test. Click the step with the ELSE

statement. The step changes to a list. 7. From the list, select STEP GENERATOR. The STEP GENERATOR dialog box appears. 8. In the STEP GENERATOR dialog box, from the CATEGORY list, select FUNCTIONS. 9. From the LIBRARY list, select ALL. The ALL function library appears. 10. From the OPERATION list, select INVOKEAPPLICATION. 11. In the ARGUMENTS section, select the COMMAND row. 12. In the VALUE column, type the absolute path for the Flight Reservation application:

Page 28: QTP Lab Exercises

13. Click OK. 14. Run the test. Note: It takes a few seconds to view the test run. 15. In KEYWORD VIEW, select the last step. 16. From the QuickTest Professional menu bar, select INSERT → NEW STEP. A new step is added. 17. From the list, select OBJECT FROM REPOSITORY. The SELECT OBJECT FOR STEP

dialog box appears. 18. In the SELECT OBJECT FOR STEP dialog box, in the object repository tree, select the LOGIN window object and click OK. 19. In the KEYWORD VIEW, select the LOGIN step. 20. From the QuickTest Professional menu bar, select INSERT → NEW STEP. A new step is added. 21. From the list, select AGENT NAME. 22. In the VALUE column, type LAURENCE. 23. From the QuickTest Professional menu bar, select INSERT → NEW STEP. A new step is added. 24. From the list, select PASSWORD. 25. In the VALUE column, type MERCURY. 26. From the QuickTest Professional menu bar, select INSERT → NEW STEP. A new step is added. 27. From the list, select OK. 28. Close the LOGIN window. 29. Save the test as LABCH9_5. 30. Run the test.

Page 29: QTP Lab Exercises

31. View the test results. Note: Verify that the ELSE statement was executed.

32. Close the QuickTest Professional and Flight Reservation applications.

Page 30: QTP Lab Exercises

Exercise: 9. Creating a Test on a Web Application In this exercise, you prepare for, create, and verify a test to test the functionality of the new flight reservation process of the Mercury Tours Web application. In this exercise, you:

• Verify that a new flight reservation can be made for one to four passengers (hint: standard checkpoint).

• Verify that the YOUR ITINERARY HAS BEEN BOOKED! text appears on the FLIGHT

CONFIRMATION Web page (hint: text checkpoint).

• Verify that the transaction is successful for three different combinations of cities (hint: parameters). This exercise consists of the following parts: Part 1: Prepare the test environment. Part 2: Record a test on the Web application. Part 3: Insert a standard checkpoint and a text checkpoint. Part 4: Use parameters to store city names. Part 1: Prepare the Test Environment 1. Open QuickTest Professional. 2. In the QUICKTEST PROFESSIONAL - ADD-IN MANAGER dialog box, check the WEB

check box. 3. Click OK. 4. Open a blank test. 5. Click START → PROGRAMS → MERCURY TOURS → START SERVER to start the Apache Web server. 6. Verify that the START SERVER window displays the following line: Apache/1.3.17 <Win32> ApacheJServ/1.1.2 running... 7. Minimize the START SERVER window. 8. Click START → PROGRAMS → MERCURY TOURS → MERCURY TOURS. 9. Specify the following user name and password to log on to the Mercury Tours application: – Username: JOJO

Page 31: QTP Lab Exercises

– Password: BEAN

10. Click SIGN-IN. Ensure that the FLIGHT FINDER Web page appears. Note: The FLIGHT FINDER Web page is the initial and end condition for creating this test. Part 2: Record a Test on the Web Application 1. On the QuickTest Professional toolbar, click RECORD. The RECORD AND RUN

SETTINGS dialog box appears. 2. Ensure that the RECORD AND RUN TEST ON ANY OPEN BROWSER option is selected and click OK. 3. On the FLIGHT FINDER Web page, specify the following flight information: – TYPE: ROUND TRIP

– PASSENGERS: 4

– DEPARTING FROM: NEW YORK

– ON: JULY 5 – ARRIVING IN: PARIS

– RETURNING: JULY 25 – SERVICE CLASS: BUSINESS CLASS

– AIRLINE: NO PREFERENCE

4. Click CONTINUE. The SELECT FLIGHT Web page appears. 5. Click CONTINUE to accept the default flight. The BOOK A FLIGHT Web page appears. 6. In the PASSENGERS section, specify the following data: – FIRST NAME: JOSEPH

– LAST NAME: WILLIAMS

– MEAL: NO PREFERENCE

7. Type other passenger names: NANCY WILLIAMS, JAMES WILLIAMS, and BARBARA WILLIAMS. Set their MEAL to NO PREFERENCE. 8. In the CREDIT CARD section, specify the following data: – CARD TYPE: DEFAULT

– NUMBER: 1234567890 – EXPIRATION: 12-2008

Page 32: QTP Lab Exercises

9. Click SECURE PURCHASE to book a flight. 10. On the left side of the FLIGHT CONFIRMATION Web page, click the FLIGHTS

link to set the initial condition for the test. 11. On the QuickTest Professional toolbar, click STOP. 12. Save the test as LABCH10_2. Part 3: Insert a Standard Checkpoint and a Text Checkpoint 1. In KEYWORD VIEW, select the PASSCOUNT step that has the value 4 in the VALUE

column. 2. From the QuickTest Professional menu bar, select INSERT → CHECKPOINT → STANDARD CHECKPOINT to verify that a maximum of four passengers are allowed for a new flight reservation. The CHECKPOINT PROPERTIES dialog box appears. 3. Check the ALL ITEMS check box. Uncheck remaining check boxes. 4. Select the AFTER CURRENT STEP option. 5. Click OK. 6. In KEYWORD VIEW, select the FLIGHT CONFIRMATION: MERCURY step. 7. In ACTIVE SCREEN, select the YOUR ITINERARY HAS BEEN BOOKED! text and right-click the text. 8. Select INSERT TEXT CHECKPOINT. The TEXT CHECKPOINT PROPERTIES dialog box appears. 9. Ensure that the BEFORE CURRENT STEP option is selected. 10. Click OK. Part 4: Use Parameters to Store City Names 1. In KEYWORD VIEW, click the VALUE column of the FROMPORT step. The CONFIGURE THE VALUE button appears. 2. Click the CONFIGURE THE VALUE button.

Page 33: QTP Lab Exercises

3. In the VALUE CONFIGURATION OPTIONS dialog box, select the PARAMETER option. 4. In the NAME field, type FROMPORT. 5. Click OK. 6. Perform steps 1 to 5 for the TOPORT step and name the parameter as TOPORT. 7. In DATA TABLE, type the following names of cities in the FROMPORT column: – FRANKFURT

– LONDON

– PORTLAND

8. In DATA TABLE, type the following names of cities in the TOPORT column: – SEATTLE

– ZURICH

– SYDNEY

9. Save the test as LABCH10_4. 10. Run the test and view the test results in the TEST RESULTS window. The test passes.

11. Close the QuickTest Professional application and the Mercury Tours Web browser.

Page 34: QTP Lab Exercises

Exercise: 10. 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 PRICECHK parameter. 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: a) DATE OF FLIGHT: 12-12-09

b) FLY FROM: Frankfurt

c) FLY TO: London

d) NAME: Sam Smith

e) TICKETS: 2

f) CLASS: First

3. Save the test as LABCH11_1. 4. Run the test. The test playback should be successful. 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 INSERT OUTPUT VALUE to create an output parameter. The OBJECT

SELECTION - OUTPUT VALUE PROPERTIES dialog box appears. 4. Click OK. The OUTPUT VALUE PROPERTIES dialog box appears.

Page 35: QTP Lab Exercises

5. Check the TEXT check box and click MODIFY. The OUTPUT OPTIONS dialog box appears. 6. In the NAME field, type NTICKETS. 7. Click OK to close the OUTPUT OPTIONS dialog box. 8. Select the AFTER CURRENT STEP option. 9. Click OK to close the OUTPUT VALUE PROPERTIES dialog box. 10. Verify that: a) A TICKETS step appears in KEYWORD VIEW that has the OUTPUT value in the OPERATION column. b) 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 PARAMETER NAME dialog box appears. 14. In the DATA TABLE COLUMN NAME field, type PRICECHK. 15. Click OK. The new column name appears in the DATA TABLE. 16. Save the test as LABCH11_2.

Part 3: Use a Formula in the Data Table 1. In the GLOBAL sheet of DATA TABLE, specify test data for the following fields: a) NTICKETS: 1 b) PRICE: 123 c) TOTAL: 123 2. For the first row under the PRICECHK column, type the following formula: =ROUND(A1*B1,2)=ROUND(C1,2) 3. To perform the calculation, press ENTER. The TRUE value appears in the PRICECHK column.

Page 36: QTP Lab Exercises

4. Change the value of NTICKETS to 2 and press ENTER. The FALSE value appears in the PRICECHK column. 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 STEP GENERATOR dialog box appears. 3. In the CATEGORY list, select UTILITY OBJECTS. 4. In the OBJECT list, select DATA TABLE. 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 OK to insert this step into the test. 10. From the QuickTest Professional menu bar, select INSERT→ CONDITIONAL

STATEMENT → IF ... THEN. 11. 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.

Page 37: QTP Lab Exercises

6. In KEYWORD VIEW, select the IF statement. 7. From the QuickTest Professional menu bar, select INSERT→ CONDITIONAL

STATEMENT→ ELSE. The ELSE statement 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. 10. In the NAME field, type TOTAL. 11. In the DETAILS field, type TOTAL WAS NOT CALCULATED SUCCESSFULLY. 12. Click OK. 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 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. 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. Note: The number of tickets can be 1-10, inclusive of 1 and 10. 4. On the QuickTest Professional toolbar, click RUN. The test continues to run from the breakpoint step.

Page 38: QTP Lab Exercises

5. Open the TEST RESULTS window. The test fails. 6. Expand all steps in the TEST RESULTS window to view the output of the REPORTER

step. 7. Check the values in RUN-TIME DATA TABLE to see which values passed. 8. Close the QuickTest Professional and Flight Reservation applications.

Page 39: QTP Lab Exercises

Exercise: 11. 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. Note: Do not select any add-ins. 2. On the QuickTest Professional toolbar, click NEW. 3. Open and log on to the Flight Reservation application. 4. Record a new reservation that includes the following flight information: a) DATE OF FLIGHT: 12-12-09

b) FLY FROM: Frankfurt

c) FLY TO: London

d) NAME: Sam Smith

e) TICKETS: 2

f) CLASS: First

5. Click INSERT ORDER. 6. From the QuickTest Professional menu bar, select INSERT → SYNCHRONIZATION

POINT after the progress bar completes. The cursor changes to a pointed finger. 7. In the FLIGHT RESERVATION window, in the progress bar, click the words INSERT

DONE... with the pointed finger cursor. 8. In the OBJECT SELECTION - SYNCHRONIZATION POINT dialog box, click OK. The ADD SYNCHRONIZATION POINT dialog box appears. 9. From the PROPERTY NAME list, select TEXT.

Page 40: QTP Lab Exercises

10. In the PROPERTY VALUE field, type "INSERT DONE...". 11. In the TIMEOUT field, retain the default value. 12. Click OK. 13. In the FLIGHT RESERVATION window, click the NEW ORDER button to set end conditions for the test. 14. On the QuickTest Professional toolbar, click STOP to stop the test. 15. Save the test as LABCH12_1. 16. In KEYWORD VIEW, select the INSERT DONE step. 17. 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. 18. Click OK. The OUTPUT VALUE PROPERTIES dialog box appears. 19. Check the TEXT check box, and click MODIFY. The OUTPUT OPTIONS dialog box appears. 20. In the NAME field, type GUIORDER_NO. 21. Click OK to close the OUTPUT OPTIONS dialog box. 22. In the OUTPUT VALUE PROPERTIES dialog box, select the AFTER CURRENT STEP

option. 23. Click OK to close the OUTPUT VALUE PROPERTIES dialog box. 24. Verify that: a) The KEYWORD VIEW has an ORDER NO step that has the OUTPUT value in the OPERATION column. b) The GLOBAL sheet of DATA TABLE has a column named GUIORDER_NO. 25. Repeat steps 17 to 24 to create an output parameter for the number of tickets and name it as NTICKETS. 26. Save the test. 27. Run the test to verify that the new order number and the number of tickets are

Page 41: QTP Lab Exercises

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 DATABASE QUERY WIZARD appears. 3. In the QUERY DEFINITION section, ensure that the CREATE QUERY USING

MICROSOFT QUERY option 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 USE MICROSOFT QUERY check box is checked, and click NEXT. 7. In the INSTRUCTIONS FOR MICROSOFT QUERY dialog box, click OK. 8. In the CHOOSE DATA SOURCE dialog box, in the DATABASES list, click QT_FLIGHT32*. Note: The Flight Reservation AUT uses the QT_FLIGHT32* database. 9. Ensure that the USE THE QUERY WIZARD TO CREATE/EDIT QUERIES check box is checked. 10. Click OK. 11. 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. 12. 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. 13. In the QUERY WIZARD - FILTER DATA dialog box, click NEXT.

Page 42: QTP Lab Exercises

14. In the QUERY WIZARD - SORT ORDER dialog box, from the SORT BY list, select ORDER_NUMBER. 15. Select the DESCENDING option, and click NEXT. 16. In the QUERY WIZARD - FINISH dialog box, click SAVE QUERY. 17. In the SAVE AS dialog box, click SAVE to save the query by the default query name. The QUERY WIZARD - FINISH dialog box appears. 18. Ensure that the EXIT AND RETURN TO QUICKTEST PROFESSIONAL option is selected. 19. Click FINISH. 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. 2. Click the REMOVE FROM CHECK button to uncheck all rows currently selected. 3. Click the first cell of the ORDER_NUMBER column. 4. Click the ADD TO CHECK button to select the first cell of the ORDER_NUMBER column. 5. In the CONFIGURE VALUE section, select the PARAMETER option, and click the PARAMETER OPTIONS button. 6. In the PARAMETER OPTIONS dialog box, from the NAME list, select GUI_ORDER_NO and click OK. 7. In the DATABASE CHECKPOINT PROPERTIES dialog box, select the AFTER CURRENT

STEP option. Part 4: Set Database Checkpoint Properties for the Number of Tickets 1. Click the first cell of the TICKETS column.

Page 43: QTP Lab Exercises

2. Click the ADD TO CHECK button to select the first cell of the TICKETS column. 3. In the CONFIGURE VALUE section, select the PARAMETER option, and click the PARAMETER OPTIONS button. 4. In the PARAMETER OPTIONS dialog box, from the NAME list, select NTICKETS and click OK to close the PARAMETER OPTIONS dialog box. 5. Click OK to 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.

Page 44: QTP Lab Exercises

Exercise: 12. Administering an Object Repository This exercise enables you to create a shared object repository and associate the object repository with a test. This exercise consists of the following parts: Part 1: Create a shared object repository. Part 2: Associate an object repository. Part 1: Create a Shared Object Repository 1. Invoke QuickTest Professional. 2. Invoke the Flight Reservation application. 3. From the QuickTest Professional menu bar, select RESOURCES → OBJECT

REPOSITORY MANAGER. The OBJECT REPOSITORY MANAGER window appears. 4. On the OBJECT REPOSITORY MANAGER toolbar, click the ADD OBJECTS button. The cursor changes to a pointing hand. 5. Click the title bar of the Flight Reservation window with the pointing hand cursor. The OBJECT SELECTION - ADD TO REPOSITORY dialog box appears. 6. Click OK. The ADD OBJECT TO OBJECT REPOSITORY dialog box appears. 7. Ensure that all objects are checked. 8. Click OK. Ensure that the objects are added in the OBJECT REPOSITORY MANAGER

window. 9. From the OBJECT REPOSITORY MANAGER menu bar, select FILE → SAVE AS. The SAVE SHARED OBJECT REPOSITORY dialog box appears. 10. In the FILE NAME field, type FLIGHT.TSR. 11. Click SAVE. 12. Close OBJECT REPOSITORY MANAGER. Part 2: Associate an Object Repository 1. From the QuickTest Professional menu bar, select RESOURCES → OBJECT

Page 45: QTP Lab Exercises

REPOSITORY. The OBJECT REPOSITORY dialog box appears. 2. On the OBJECT REPOSITORY toolbar, click the ASSOCIATE REPOSITORIES button. The ASSOCIATE REPOSITORIES dialog box appears. 3. Click the ADD REPOSITORY button. The ADD SHARED OBJECT REPOSITORY dialog box appears. 4. Navigate to the directory in which you saved the FLIGHT.TSR file, and open the file. 5. In the ASSOCIATE REPOSITORIES window, in the AVAILABLE ACTIONS list, select ACTION 1, and use the right-arrow button to move the action to the ASSOCIATED

ACTIONS list. 6. Click OK. The objects are added in the local object repository. 7. Close the OBJECT REPOSITORY dialog box.

8. Close the QuickTest Professional and Flight Reservation applications

Page 46: QTP Lab Exercises

Exercise: 13. Solving Object Recognition Problems In this exercise, you solve problems related to object recognition in a test by creating virtual objects and by using analog recording. In addition, you create a bitmap checkpoint to compare the expected image to the actual image. This exercise consists of the following parts: Part 1: Record a test on Microsoft Paint using normal recording. Part 2: Identify the problems in the test. Part 3: Create a virtual object. Part 4: Perform analog recording. Part 5: Add a bitmap checkpoint. Part 1: Record a Test on Microsoft Paint Using Normal Recording 1. Open a new test in QuickTest Professional. 2. Select START → PROGRAMS → ACCESSORIES → PAINT to open the Paint application. 3. On the Paint toolbar, ensure that the pencil button is selected. 4. In the drawing area, write QTP. 5. On the QuickTest Professional toolbar, click RECORD. In the RECORD AND RUN

SETTINGS dialog box, click OK to accept the default settings. 6. From the Paint menu bar, select FILE → NEW. 7. Click NO when prompted to save the drawing. 8. From the color palette, select a color. 9. In the drawing area, write QTP. 10. From the color palette, select a new color. 11. In the drawing area, write QTP. 12. On the QuickTest Professional toolbar, click STOP. 13. Save the test as LABCH14_1.

Page 47: QTP Lab Exercises

14. On the QuickTest Professional toolbar, click RUN. Click OK to accept the RUN

settings. Part 2: Identify the Problems in the Test 1. Observe the drawing area in the Paint application. The text QTP appears distorted in the drawing area. 2. From the QuickTest Professional menu bar, select RESOURCES → OBJECT

REPOSITORY. In the OBJECT REPOSITORY tree, observe that QuickTest learns the properties of only two objects, AFX: 1000000:8 and COLORS. QuickTest does not learn the properties of the pencil button separately. 3. Close the OBJECT REPOSITORY dialog box. 4. Observe KEYWORD VIEW. QuickTest does not record the mouse movement. It records the values for the SELECT, CLICK, DRAG, and DROP operations. Part 3: Create a Virtual Object 1. On the QuickTest Professional menu bar, select TOOLS → VIRTUAL OBJECTS → NEW VIRTUAL OBJECT to open VIRTUAL OBJECT WIZARD. The WELCOME TO THE

VIRTUAL OBJECT WIZARD page appears. 2. Click NEXT. The MAP TO A STANDARD CLASS page appears. 3. From the CLASS list, select BUTTON. 4. Click NEXT. The MARK VIRTUAL OBJECT page appears. 5. Click MARK OBJECT. The cross-hairs cursor appears. 6. On the Paint application, use the cross-hairs symbol to draw a square around the pencil button. The width and height of the selected region appear in the WIDTH and HEIGHT fields on the MARK VIRTUAL OBJECT page. 7. Click NEXT. The OBJECT CONFIGURATION page appears. 8. In the IDENTIFY OBJECT USING section, ensure that the PARENT ONLY option is selected. 9. Click NEXT. The SAVE VIRTUAL OBJECT page appears.

Page 48: QTP Lab Exercises

10. In the NAME field, type PENCIL. 11. In the COLLECTION NAME box, type PAINT. 12. Select the YES option. 13. Click NEXT. The MAP TO A STANDARD CLASS page appears. 14. From the CLASS list, select TABLE. 15. In the NUMBER OF ROWS box, type 2. 16. In the NUMBER OF COLUMNS box, type 14. 17. Click NEXT. 18. On the MARK VIRTUAL OBJECT page that appears, click MARK OBJECT. 19. Use the cross-hairs cursor to draw a rectangle around the color palette in the Paint application. 20. Click NEXT. The OBJECT CONFIGURATION page appears. 21. Ensure that the PARENT ONLY option is selected, and click NEXT. The SAVE

VIRTUAL OBJECT page appears. 22. In the NAME field, type COLOR. 23. In the COLLECTION NAME box, ensure that PAINT is selected. 24. Ensure that the NO option is selected. 25. Click FINISH. Part 4: Perform Analog Recording 1. Open a new test in QuickTest Professional, and save it as LABCH14_4. 2. On the QuickTest Professional toolbar, click RECORD. Click OK to accept the default record and run settings. 3. From the Paint menu bar, select FILE → NEW.

Page 49: QTP Lab Exercises

4. Click NO when prompted to save the existing drawing. 5. From the QuickTest Professional menu bar, select AUTOMATION → ANALOG

RECORDING. The ANALOG RECORDING SETTINGS dialog box appears. 6. In the ANALOG RECORDING SETTINGS dialog box, select RECORD RELATIVE TO

THE FOLLOWING WINDOW.

Page 50: QTP Lab Exercises

Exercise: 14. Creating a Recovery Scenario for a Test In this exercise, you introduce an error in a test and then use RECOVERY SCENARIO

MANAGER to handle the error during a test run.This exercise consists of the following parts:

Part 1: Use parameters to store input values for month and year. Part 2: Run the test to check the error in the test. Part 3: Add a recovery scenario to the test. Part 4: Run the test and view test results. Part 1: Use Parameters to Store Input Values for Month and Year 1.Open QuickTest Professional. 2. In the QUICKTEST PROFESSIONAL - ADD-IN MANAGER dialog box, check the WEB

check box. 3. Click OK. 4. Open the LABCH10_2 test that you created in Chapter 10, Creating Tests on a Web Application, Exercise: Creating Tests on a Web Application. 5. Save the test as LABCH16_1. 6. In KEYWORD VIEW, expand the BOOK A FLIGHT: MERCURY step. 7. In KEYWORD VIEW, click the VALUE column of the CC_EXP_DT_MN step to store the value of month in a parameter. The CONFIGURE THE VALUE button appears. 8. Click the CONFIGURE THE VALUE button. 9. In the VALUE CONFIGURATION OPTIONS dialog box, select the PARAMETER option. 10. In the NAME field, type MONTH. 11. Click OK. 12. Perform steps 7 to 11 for the CC_EXP_DT_YR step to store the value of year in the YEAR parameter.

Page 51: QTP Lab Exercises

13. In DATA TABLE, append the following data in the MONTH column: – 11 – 10 14. In DATA TABLE, append the following data in the YEAR column: – 2005 – 2003 15. Save the test. Part 2: Run the Test to Check the Error in the Test 1. Select START → PROGRAMS → MERCURY TOURS → START SERVER to start the Apache Web server. Note: You start the Apache Web server to run the Web application. Select START → PROGRAMS → MERCURY TOURS → STOP SERVER to stop the Apache Web server. 2. Select START → PROGRAMS → MERCURY TOURS → MERCURYTOURS to launch the Mercury Tours Web application. 3. Log on to the Mercury Tours Web application using: – Username: JOJO

– Password: BEAN

Note: The FLIGHT FINDER Web page is the initial and end condition for this test. Ensure that the FLIGHT FINDER Web page appears. 4. Run the test. The message YOU HAVE ENTERED 2003 AS EXPIRATION YEAR! appears. Note: Do not close the message box. 5. A RUN ERROR message box appears. On the RUN ERROR message, click STOP. Part 3: Add a Recovery Scenario to the Test 1. Restore the QuickTest Professional window. 2. From the QuickTest Professional menu bar, select RESOURCES → RECOVERY

SCENARIO MANAGER. The RECOVERY SCENARIO MANAGER dialog box appears.

Page 52: QTP Lab Exercises

3. In the SCENARIOS section, click the NEW SCENARIO button to display RECOVERY

SCENARIO WIZARD. 4. Click NEXT. The SELECT TRIGGER EVENT page appears. 5. On the SELECT TRIGGER EVENT page, ensure that the POP-UP WINDOW option is selected. 6. Click NEXT. The SPECIFY POP-UP WINDOW CONDITIONS page appears. 7. Click the pointing hand button, and then click the pop-up error message box that appears in the Mercury Tours Web application. 8. On the SPECIFY POP-UP WINDOW CONDITIONS page, click NEXT. The RECOVERY

OPERATIONS page appears. 9. Click NEXT to define a recovery operation. 10. Ensure that the KEYBOARD OR MOUSE OPERATION option is selected. Click NEXT. 11. On the RECOVERY OPERATION - CLICK BUTTON OR PRESS KEY page, select the CLICK BUTTON WITH LABEL option. 12. Click the pointing hand button, and then click OK on the pop-up error message box that appears in the Mercury Tours Web application. 13. Click NEXT. The RECOVERY OPERATIONS page appears. 14. Clear the ADD ANOTHER RECOVERY OPERATION check box. 15. Click NEXT. The POST-RECOVERY TEST RUN OPTIONS page appears. 16. Select the PROCEED TO NEXT STEP test run option. 17. Click NEXT. The NAME AND DESCRIPTION page appears. 18. In the SCENARIO NAME field, type CREDIT CARD DATE ERROR. 19. In the DESCRIPTION field, type AN INVALID DATE WAS ENTERED IN THE CREDIT

CARD DATE FIELD.