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:
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:
2. One can add the properties additionally apart from the default ones by clicking on "+" button and remove it using "x" button. If we want to restore to defaults we can click on the "circular arrow" button.
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.
4. 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 are 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".
5. 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. Eg : Click for a button, Set for a Text Box etc.