Object Repositories and Object Repository Manager
Today’s topic is Object repositories. In the previous articles, we have discussed how QTP identifies and stores objects in a warehouse, the OR. We also have seen how the object properties appear in the OR. To quickly recap, we will take a look at the OR screen. You can launch it from your current test by clicking on the icon or from the “Resources->Object Repository” option.It launches the following Object repository dialog box:
Points to note here:
- The objects are stored in a hierarchical manner.
- This is a local repository that contains the objects for Action1.
- If the action had any checkpoints the same would have been available in this dialog to edit.
A shared object repository stores objects in a file that can be accessed by multiple tests (in read-only mode).
One of the important aspects when planning your tests (or choosing a framework for your project) is to consider where and how you want your objects to be stored and how they have to be made available to the tester.
The following are some Object Repository types in QTP:
- Local ORs- each action will have its objects stored in its local repository
- Shared ORs – all the actions will refer to a single read only OR
- Local and Shared ORs- an action can use both local and multiple shared ORs.
We will see how a shared OR is created and how we can move objects to and from a shared OR to local or vice versa.
To maintain ORs in your test there is a specialized Object Repository Manager that QTP provides. It can be accessed from the menu item “Resources->Object Repository Manager”.
Using ORM you can do the following:
- Creating New Object Repositories
- Opening Object Repositories
- Saving Object Repositories
- Closing Object Repositories
- Managing Objects in Shared Object Repositories
- Managing Repository Parameters
- Modifying Object Details
- Locating Test Objects
- Performing Merge Operations
- Performing Import and Export Operations
To create a shared OR (.tsr) file, launch ORM. A new repository will open up or you can explicitly do so by using the option “File->New”. Any OR is only as good as the objects it has. So the next step is obviously to add objects.
There are 3 ways you do that from here:
Method #1) Define Test objects. “Object->Define Test Object” – on choosing this option the following dialog appears:
In here, you can specify environment, Class, Name, Properties and Add the object to the repository. The screenshot can be a sample data you could enter.
Method #2) Add Objects: On choosing this option, the pointy hand gets active, QTP gets minimized and when you click on the object you wish to add, the following dialog shows up and you can add the object.
Method #3) Navigate and Learn: This is the most interesting and most used way. As the name indicates, you just have to instruct QTP to ‘navigate and learn’, point to an object in your app and QTP automatically gets the objects depending on your filter settings. Choose this option from the menu or hit F6, in the screenshot notice the little navigate and learn dialog on the top of the page. Now Hit the Learn button in the dialog and click on the page. Navigate as many pages and hit learn as many times as required. Once done, close the “Navigate and Learn” dialog.
The filter options are as follows:
I chose “All Object Types” from the dialog and clicked on the main gmail.com page, the following are the objects that get added to the OR:
Using any of the above ways create a shared ORM, add objects and save it.
There is another way objects can be added to a shared OR. It is from the local OR.
Open your test or create a new test. Gmail Login- our example. Launch the OR for this test. It looks like this:
I want to create a shared OR that contains the Email, password and Sign In objects. The “File” Menu has 2 options under it, “Export Local Objects” and “Export and Replace Local Objects”. You can use either one of these options.
If you use “Export Local Objects”, the local objects are exported to the specified shared object repository (a file with a .tsr extension). Your test continues to use the objects in the local object repository, and the new shared object repository is not associated with your test.
With “Export and Replace Local Objects”, the new shared object repository (a file with a .tsr extension) is associated with your test, and the objects in the local object repository are deleted.
Choose any of the options and choose the shared OR to export to.
Associating the shared Object Repository to your test
After you decide to use a shared OR for your test, create one and add objects to it, the tester has to explicitly include the .tsr file to the test to be able to use the objects in it.To do so, go to “Resources->Associate Repositories”. The following dialog box opens up:
Click on the “+” sign. Choose the OR. Once you choose it, all the actions that are available in your test will appear under the “Available Actions” box.
Select as many or as few as you would like. I just have one, so I am going to go ahead and choose it. Click OK when done.
On successful association, the shared OR will appear in the Resources pane if it is already visible or you can launch the same from “View->Resources” option.
If you want to remove the association, you can right click on the .tsr in the resources pane and select “Remove Repository from List” option. Or you can go to “Resources->Associated Repositories” menu option, select the shared ORM to remove and click on the cross sign.
For rules on how a shared OR and Local OR will work, please refer to our tutorial #8. Though there are many other features to ORM and OR, we will limit ourselves to what we have learned in this article as they are the most useful ones. The rest of them are very easy for any tester to figure out on their own once they read this article.
No comments:
Post a Comment