QTP - Working with Object Repository



Adding Objects into OR

After Spying the object, adding the objects into Repository is the first step. The script can execute successfully if and only if the objects are added into the Object Repository. Upon Clicking "Add Objects to OR", the objects are added into Object repository.

Even when a user does a recording, the objects and its properties are captured automatically. Hence, we are able to replay the script successfully.

Object Repository – Features

Step 1 − After adding objects to the OR, we can verify by navigating to "Resources" → "Object Repository". The Object Repository Window opens and we can locate the added object in the Repository as shown below −

Object Repository

Step 2 − One can add the properties additionally apart from the default ones by clicking the "+" button and remove it using the "x" button. If we want to restore the defaults, we can click on the "circular arrow" button.

Object Repository

Step 3 − One can change the object's name. Here the name of the object is "Numbers" that can be renamed to "num", which will not have any effect on identifying the object uniquely. If there is a change in logical name, the same name should be used while scripting. Only the Object's Name can be changed and not its properties.

Rename Objects

Note − Properties of any object must be unique so that QTP will be able to recognize the objects and act on it. If the object properties were same for two or more objects, then during execution an error would be thrown that "More than one object is matched for the specified properties".

Step 4 − After adding the objects, the same can be used in script by simple drag-drop as shown in the figure. When the object is dragged and dropped, the default operation is set. For example, click for a button, Set for a Text Box etc.

Rename Objects
qtp_object_repository.htm
Advertisements