UFT/QTP – Object Repository

An Object is an element that is present in the application . All the elements of the applications are considered as objects. Each object belongs to particular class like list box, edit box, button. image, link etc.

Object Repository is a collection of object and properties with which QTP 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, QTP will NOT be able to play back the scripts.

Object repository acts as a container to store test objects. Test object is the object created by QTP in the test script to represent the object present in the application.

To open an Object Repository choose “Resources >> Object Repository”.

Object repository looks like below screen –

QTP OBJECT REPOSITORY

Object Repository – Features

  • We can add the properties 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
  • One can change the object’s Logical 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 because only the Object’s Name is changed not its Properties. If there is a change in logical name, the same name should be used in scripting.
  • Properties of any object must be unique so that QTP will be able to recognize the objects. 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”.
  • After adding the objects, the same can be used in script by simple drag-drop. When the object is dragged and dropped, the default operation is set. Like: Click for a button, Set for a Text Box etc

QTP Object Repository Info

Run-time Object – The actual object that is present in the application on which the QTP performs an operation. For example search button of Google application on which QTP test clicks when the test runs is referred as Run Time object as shown in below –

QTP Run Time Object

Object Spy:- Object Spy is used for viewing the Properties and Methods of any object in an application. You use the Object Spy pointer to point to an object. The Object Spy displays the selected object’s hierarchy tree and its properties and values in the Properties tab of the Object Spy dialog box.

Navigation

  • From menu bar icon as shown below
    QTP Object Spy
  • Tools -> Object Spy
    QTP_Object_Spy
  • Resources -> Object  Repository Manager
    QTP_Object_Spy
  • Resources -> Object Repository
    QTP_Object_Spy

Upon Clicking on the above navigation options, the Object Spy Dialog box opens.

 

QTP Object Spy Info

Understand Object Spy UI –

Hand – This is the point where you can start my interaction with the objects, just click it and move hand over the required object and will provide you the run time object properties. Moreover you can press CTRL key to hide my hand to perform normal operations of mouse.

Highlight – This feature will be disabled until and unless no object is added to UI. One’s the object is added it will help you highlight that particular object in the application. (with a blink around that object)

QTP_Object_Spy_Info_with_properties

Note: Incase not able to find the object due to nonexistent of object or properties are not unique, It will generate an error message like below.

QTP Object Spy error

Add object to object repository – Using this feature you can add the selected object to object repository.

Note:

  • Only the selected object from the hierarchy will be added to OR
  • One’s that object is added to OR, this button will become disabled.
  • Object will be added to local Object repository incase object spy launched from Local object repository or from menu bar icon or from tools options. object will add to shared OR only incase object spy launched from object repository manager.

Copy to clipboardClick on this button to copy all the object properties in ,name:=value pair combination. Paste them in any of the editor to see all the properties.

Note:- This feature is important while working with descriptive programming in UFT, as you can utilize this properties in descriptive programming.

Keep me on Top while spying – You can keep me on the top of the application while hand button is active or make me invisible while object spy is active.

Object Repository(OR) Types –

Depending on the way objects are stored and used by UFT test script, Object repositories are divided in two types.

  1. Local Object Repository
  2. Shared Object Repository

Local Object Repository

In this type of repository, the objects are stored for a particular action and only that particular action can access the stored objects. As we know that UFT creates a New Test with 1 action by default. An action is nothing but  few lines of code in the UFT Script. One script can contain multiple actions. If you are recording some operations on the application first you must choose in which action of the UFT script must be recorded. Local Object Repository can be opened by traversing to Resources → Object Repository. This is the default OR in QTP.

QTP Object Repository Info

Shared Object Repository

A shared object repository contains objects that can be shared by multiple actions of the same test script or different test script. A shared object repository stores in the form of a file with extension .tsr which stands for test shared repository.

Local objects can be exported to be saved into Shared Object Repository by using the option “Export Local Objects” Options. Shared Object Repository can be opened by traversing to Resource → Object Repository Manager

QTP SHARED OBJECT REPOSITORY

Points to remember:-

  • When a test is recorded objects are by default stored in local object repository.
  • A test can use a combination of repository types. That is a test can use both local and shared repository together.
  • If an object with the same name is located in both the local object repository and in a shared object repository, the action will use the local object repository.
  • A test can be associate with many shared repositories.
  • If same name object is located in more than one shared object repository, the object is used from the first occurrence of the object, according to the order in which the shared object repositories are associated with the action.

Object Repository as XML

Object Repository can be saved in XML format so that size of the Object repository is reduced. The Object Repository (OR) can be saved as XML by “Exporting as XML” from Shared object Repository Window as shown below :

The Same object repository can be imported from XML and can be edited/deleted and exported back to XML.

Navigation – Resources >Object Repository Manager > File > Export to XML

QTP_Object_Repository_XML

Object Repository Comparison Tool

The  object repository comparison tool is used to compare two repositories for similarities and variations among the objects. This tool compares for different object names, descriptions(properties and values of each object) in the two repositories.

QTP Object Repository Comparison

Merging Object Repositories

The object repository merge tool is used to merge two object repositories into a single repository.

Steps

  • Go to object repository “Resources > Object Repository Manager”, In Object Repository Manager select Tools > Object Repository Merge  Tool. The following new merge window will be opened
    QTP_Object_Repository_Merge
  • Select the files that have to be  merged
    QTP_Object_Repository_Select_Merge_Files
  • Click OK. the Object Repository Merge tool automatically merges the selected object repositories into a new target object repository.
  • Click close.

Leave a Reply

Your email address will not be published. Required fields are marked *