As the name suggests, Shared Object Repository can share the objects across various tests. Shared object repository can be created through Object Repository Manager. After creating the shared repository, it needs to be associated with a particular test. Then the objects stored in the repository are accessible to the associated test / action. The biggest advantage of this type of repository is that if the application undergoes frequent user interface changes then the repository can be updated at only one place instead of updating all the local repositories for each test.
Follow the below steps to create Shared Object Repository:
- Open QuickTest Professional
- In the QTP window click on Resources –> Object Repository Manager
- Click File –> New in Object Repository Manager
- Click Objects –> Add Objects
- Mouse pointer gets turned to “hand” symbol –> click the object to be added
- Added objects are displayed in a tree structure
We will create test scripts for two end-to-end test scenarios:
- Login –> Insert New Order-> Logout
- Login –>Update Existing Order –> Logout
First, let us go ahead and create a shared object repository (flightshared.tsr)and then associate the repository with both the tests.
To add objects to the object repository we can also follow below steps:
- Click on Add Objects
- Click on the Main Window / Dialog
- Define Object Filter popup comes up
- Click on Default object types radio button
- Click OK
- This adds all the default objects to the Object Repository
- Using highlight icon (as shown in the below figure) find out the object on the application
- Give a logical name which should be easier to identify the object
- Save the object repository
Create a new test in QTP
Save the test as “InsertNewOrder”
Associate the test with newly created Shared Object Repository (flightshared.tsr)
- Click on Resources –> Associate Repositories
- Click Add button (+)
- Select the File (flightshared.tsr)
- Click on Arrow button (>) to associate with the action
Write the following code (the process of creating the code is explained in previous post)
'Script "Inserts an Order into the Flight application 'Author - Seetaram Hegde 'Copyrights - All rights reserved SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open" Dialog("Login").WinEdit("AgentName:").Set "admin" Dialog("Login").WinEdit("Password:").Set "mercury" Dialog("Login").WinButton("OK").Click Window("FlightReservation").WinMenu("Menu").Select "File;New Order" Window("FlightReservation").ActiveX("DateOfFlight").Type "120212" Window("FlightReservation").WinComboBox("FlyFrom").Select "Denver" Window("FlightReservation").WinComboBox("FlyTo").Select "Frankfurt" Window("FlightReservation").WinButton("flights").Click Window("FlightReservation").Dialog("FlightsTable").WinButton("OK").Click Window("FlightReservation").WinEdit("Name").Set "Karthik" Window("FlightReservation").WinRadioButton("Business").Set Window("FlightReservation").WinButton("InsertOrder").Click Window("FlightReservation").WinMenu("Menu").Select "File;Exit"
Execute the Script by clicking on “Run” button or F5
This should successfully execute the script.
To demonstrate the usage of this shared object repository, we will add some more objects to the flightshared.tsr which are necessary for the second test.
Follow the above steps to add the additional objects:
- SearchResults – Dialog (All the default objects)
- OpenOrder – Dialog (All the default objects)
Save the object repository
Create a new test in QTP
Save the test as “UpdateOrder”
Associate the test with newly created Shared Object Repository (flightshared.tsr) as described above.
'Script "Updates an existing Order in the Flight application 'uses name of the customer to select the record 'Author - Seetaram Hegde 'Copyrights - All rights reserved SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open" Dialog("Login").WinEdit("AgentName:").Set "admin" Dialog("Login").WinEdit("Password:").Set "mercury" Dialog("Login").WinButton("OK").Click Window("FlightReservation").WinMenu("Menu").Select "File;Open Order..." Window("FlightReservation").Dialog("OpenOrder").WinCheckBox("CustomerName").Set "ON" Window("FlightReservation").Dialog("OpenOrder").WinEdit("CustomerName").Set "Arun" Window("FlightReservation").Dialog("OpenOrder").WinButton("OK").Click Window("FlightReservation").Dialog("OpenOrder").Dialog("SearchResults").WinButton("OK").Click Window("FlightReservation").WinRadioButton("Economy").Set Window("FlightReservation").WinButton("UpdateOrder").Click Window("FlightReservation").WinMenu("Menu").Select "File;Exit"
Execute the script with Run or F5. This should successfully run the script. After the execution results window will appear. We will discuss the results window in detail in the future posts.
please send me the detailed steps to learn more about QTP
Sure Deepa
Hi, Can you please tell me how can we access one script from shared object repository, If there are 100 Scripts