Different Types of Object Repositories

In this Chapter I will explain various types of Object repositories (OR).

You should be familiar with “What is Test?” and “What is Action?” in QTP for understanding the types of object repositories.

There are two types of Object Repositories available in QTP.

They are,

1. Local object Repository (Previously it was called as per-action)

2. Shared Object Repository.

Local Object Repository

Local Object Repository stores Test Objects in a file associated with each Action. i-e Each action will have its own local object repository.

These objects can be edited from the corresponding Action.

This local object repository can NOT be used and/or edited by any other Actions within the same Test.

You can see separate ObjectRepository.bdb file inside each Action sub folder within the Test folder when you see them thro’ windows explorer.

The local object repository will be created automatically and the Test objects will be automatically stored in the Local repository while doing recording.

Shared Object Repository

A shared object repository stores test objects in a file( normally .tsr file) that can be accessed by multiple Actions/Tests in read-only mode.

We need to create this Shared Object Repository manually from Object Repository Manager.

We can export the local object repository objects into the Shared Repository file.

Associating Repositories

Each Action can use the objects from local object repository and from multiple shared object repositories.

Association of Object repositories can be done easily from the “Associate Repositories” Dialog window which will be opened from Tools->Associate Repositories menu in the Object Repository window.

By storing objects in shared object repositories and associating these repositories with Actions/Tests in your Test, you enable multiple Actions/Tests to use the objects.

It will improve maintenance of the script.

Since each Action is allowed to take objects from many places (Local object repository and multiple Shared object repositories), you should know how QTP will handle if object with same name is located in more than one repository.

QTP will give high priority to the local object repository. It will use the object from the Local object Repository if it finds object with same name in many repositories.

And, if more than one shared object repositories are having same object (i-e object with same name, properties may vary), QTP will use the object based on the order of association.

Since the shared object repository improves maintenance and enhances the re-usability, we should use them in our Automation project.

Local object repository can be used for learning purpose. Since they are getting created automatically, it will be easy to use for the beginners.

Understanding Object Repository

Object Repository is a centralized place for storing Properties of objects available in AUT (Application Under Test).

Why Centralized place? And, Why we should store the properties of objects available in AUT?

First, I will explain below things which will be helpful for understanding answers of above questions.

– All software applications and websites are getting developed using many different components or small units (e.g textbox control in vb, input tag in HTML, webbrowser contorl in .net) which can be called as Objects.

– Each object will be identified based on the object type. And also, each object will have its own properties (e.g name,title,caption,color,size) for helping to identify by each of them. And also, each object is having specified set of methods.

– Some of the properties can be changed during run-time. These are known as RO (Runtime object) properties. And some of them can not be changed. They are known as TO (Test Object) properties.

– You can use ObjectSpy available in QTP IDE to see the TO properties & methods and RO properties & methods of any object available in your application. (Make sure that required add-ins are available).

If you see TO and RO properties of many objects in different applications using ObjectSpy, you will be in a position to distinguish between TO and RO properties.

– Since TO properties are used for uniquely identifying any object, QTP will store only the TO properties of any object in the Object Repository.

– QTP will store TO properties of any object of AUT in Object repository as Name & Value pair. You can refer the below screenshot.


– The Objects stored in the Object repository(OR) are called as Test Objects. Actually it is just equivalent to the corresponding actual object in AUT.

– All the Test Objects that are stored in Object repository(OR) are arranged in a hierarchical structure. (e.g Browser->Page->webelement).

– QTP will store the TO properties of the Objects in many different ways.

  • One simple way is, while doing Recording the TO properties will be stored to the OR.
  • Second way is, TO properties can be stored by pointing the mouse cursor to required object in the AUT.
  • Another way is manually adding the TO properties of the objects to the OR.

– Note that QTP won’t store all the TO properties of the objects into the Object Repository. Only few properties will be stored to the OR, based on the setting done in Object Identification window. Refer the below screenshot. It can be opened from QTP IDE (Tools->Object Identification).

-Sometimes, QTP will store some additional properties such as index, location which are known as ordinal identifiers. Actually these properties won’t be available in the object of AUT. It will be created by QTP automatically to distinguish two objects which are having exactly same TO properties. (e.g Some forms in the web pages will be have two submit buttons, one at top and another at bottom. QTP can identify them only based on location or index).

-Note that even QTP is storing TO properties based on properties of object of AUT (i-e real object), there is no need for all the TO properties to be available in RO properties collection also. (ie) QTP can derive (i-e do some manipulation) to get some new TO properties from one or many RO properties.

-Script can get TO properties of Test Objects using methods such as getTOproperty and getTOproperties. Even, TO property of TestObject can be changed using setTOproperty. But anyway, it will be valid only till exiting the execution. After completing the execution it will resume the actual TO property stored in the OR.
During run-time we can get the property of the runtime object using getROproperty.

-Till this point we have seen about storing the Test Objects in Object Repository.
During Run mode, QTP will use these stored properties for comparing them with properties of actual objects of AUT to identify them.

– These Test objects can be represented in the script as ObjectType and Object name. (e.g Window(“Mozilla Firefox”).Activate).

– The object repository will support editing of properties of Test Object and new properties can also be added to them.

– The value for the properties of the Test Objects in OR need not be a constant. We can parameterize the values so that the TO property can be dynamically changed for each iteration of execution.

Now we can come to our Initial question. By storing properties in the centralized place, maintenance and updation of Test scripts can be easily done whenever there is a change in UI (User Interface) of the AUT.
Assume that Login screen is used in around 20 Test scripts. If the Page name of login screen in changed, we need not make any change in all these 20 Test scripts. Just changing the property of Test Object in OR is enough.

Clear understanding of Object Repository is essential if you are willing to use QTP extensively. Because we may face lot of difficulties/challenges while working with QTP. We should have clear knowledge in OR to face/solve them. Just Recording and Playback won’t help much. And also, Test Automation framework can be done very effectively only when you are familiar with understanding/handling of Object Repository.