Object Repository is collection of objects and properties with which UFT will be able to recognize the objects and act on it. When a user records a test, the objects and its properties are captured by default. Without understanding objects and its properties, UFT will not be able to play back the scripts.
Object Repository types in QTP:
- Local Object Repository– 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.
To maintain ORs in our 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
In this example, we will see how to create a shared OR for a test, understand how it can be associated and see how the objects can be used.
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: