UFT Object Repositories

No comments

UFT recognizes each entity of the application under test as an object. Each object is recognized uniquely by its set of properties and respective values.

Object Repository is a collection of objects with their respective unique properties using which UFT will be able to recognize the objects in the application and act on it.

UFT provides Object Spy utility to add objects to the Object Repository. Also, when a user records a test, the objects and its properties are captured by default.

Object Repository – Features

After adding objects to the Object Repository (OR), we can verify by navigating to ‘Resources’ -> ‘Object Repository’. The OR window opens and we can locate the added object in the Repository as shown below. Here, we have added few objects from ‘www.amazon.com’ site.

We can add the properties additionally apart from the default ones by clicking on the ‘+’ button and remove it using the ‘x’ button. If we want to restore the defaults, we can click on the ‘circular arrow’ button.

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.

Types of Object Repositories

Local Object Repository (LOR)Shared Object Repository (SOR)
This Object Repository is available; one for each action.This type of OR is available for multiple tests and for multiple actions.
This is the OR that is available for each test, by default.This type of OR is usually used in frameworks considering reusability and maintainability.
Local Object Repository is editable in Object Repository.Shared Object Repository is read-only by default but can be edited in Object Repository Manager.
It is NOT a standalone file that can be edited.SOR is a standalone file that can be edited easily.
It is saved with an Extension .bdbSOR is saved with an extension .tsr
It should be used when not many tests are working on the same screens of the application under test.SOR should be used when there are different scripts interacting with the same type of the object.

User-defined Objects

In some cases, when the application does not use standard windows classes, the objects do not get recognized by UFT. In such cases, UFT uses Class Name to find the type of Object.

When we try to add such kind of object, it might recognize as WinObject.

Hence, we can map that WinObject to behave like (for eg) ‘CheckBox’ Object type by navigating to Tools -> Object Identification and select Environment as ‘Standard Windows’ and click on ‘User Defined’ button.

Descriptive Programming to handle Objects

Object Repository is ideally used when the application is not dynamic. Descriptive programming is used when an object is not stored in the object repository. So UFT will not search for object properties in object repository but will take from descriptive programming statement. An example is shown below:

'Example1: Syntax for creating a Descriptive Object
Set MyDescription = Description.Create()
MyDescription("property").Value = "property-value"

'Example2: for writing descriptive code to perform operations on an open application
'Set search text box with value 'Books'
Browser("CreationTime:=0").Page("name:=Amazon.com: Online Shopping").WebEdit("name:=field-keywords","html tag:=INPUT").Set "Books"

'Click on 'Go' button
Browser("CreationTime:=0").Page("name:=Amazon.com: Online Shopping").WebButton("name:=Go","html tag:=INPUT").Click

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s