All You Need to Know About Object Identification in UFT

Every application consists of different objects like Button, Text Boxes, Radio buttons, and drop-downs, etc. UFT has a very strong mechanism to identify objects. For UFT, every object is a test object and each object contains certain properties (e.g. ID, Name, Index, etc.). Object Identification in UFT is done by following a certain process. In this article, I will show you how UFT identifies objects at runtime.

Object Identification in UFT

During the recording of a script, UFT learns the properties of the objects on which an operation is performed and stores the test objects in a file called Object Repository

At the time of execution, UFT compares the stored object properties with actual object properties. If the stored object properties match with the runtime object properties, UFT uniquely identifies the object and perform the required operation else it throws the runtime error “Cannot identify Object not found”

Let’s consider the following example:

Below is a sample screenshot of the HP Mercury demo tour application.

Below is the HTML Source Code for the SIGN-ON hyperlink.
UFT-HTML Source Code
The following are a few key properties of the SIGN-ON hyperlink.
  • HTML Tag for the hyperlink is “A”
  • Text is SIGN-ON 

If you open the object repository, you will see the above two properties in the Test Object Details section.

Object Repository
Now let’s see what happens after modifying the SIGN-ON text to SIGN-IN
Object Repository 2
At runtime, there happens a mismatch in the text property of the SIGN-ON test object and the script shows the error “Cannot identify the object <<Test Object Name>>”. Here the test object name is SIGN-ON.
UFT-Sample-Code
UFT RunTime error
If you restore the changes of the test object the script will click on the SIGN-ON hyperlink.

Mandatory and Assistive properties in UFT

Mandatory properties, as the name itself, suggests these are the main and core object properties of the object. At runtime initially, UFT tries to identify an object by its mandatory properties. If the mandatory property values are not sufficient to uniquely identify the object, UFT adds some assistive properties and/or an ordinal identifier to create a unique description.
Let’s try to understand this with an example:
Object Identification in UFT

As per the above screenshot, “HTML tag” and “text” of the link are the mandatory properties. During execution, if UFT is not able to uniquely identify the object it will start adding one assistive property one with mandatory properties by one until UFT is able to identify the object.

Ordinal identifiers in UFT

Ordinal-Identifier-UFT

If mandatory properties and assistive properties together are not sufficient to uniquely identify an object then UTF uses an Ordinal identifier along with mandatory properties and assistive properties to uniquely identify the required object.

Example:
If there are two links object on the screen having the same text and URL, then we can use the ordinal identifiers to identify one of the objects.

Types of ordinal Identifier in UFT

There are three types of ordinal identifier.
  1. Index
  2. Location
  3. Creation Time (applicable only for web browser and no other objects)
Index: Indicates the order in which the object appears in the application code relative to other
objects. The indexing counter starts from 0. Therefore, if you use Index:=1 to describe a WebEdit test
object, UFT will look for the second WebEdit object on the page rather than the first object.
Example: The following statement refers to the third text box in the page
WebEdit(“Name:=UserId”, “Index:=2”)
Location: Indicates the order in which the object appears within the parent window, frame, or dialog
box relative to other objects with an otherwise identical description.
ExampleWebEdit(“Name:=UserId”, “Location:=2”)

Now it seems that both Index and location are the same. So, what the difference between them.

The Index is the order, a developer has coded the controls inside the application. However, Location is the order in which it appears on the screen.

window
So if a developer creates a “Next” button first and then a “Back” button, although if the “Back” button appears on the screen first but the index for the button will be 1, and the index for the Next button will be 0.
CreationTime: Indicates the order in which the browser was opened relative to other open browsers with an otherwise identical description.

Creation time is assigned to the browsers in the sequence they are opened. If you have opened three different browsers, the creation time of the first browser would be 0, and so on.

Smart Identification in UFT

When UFT uses the learned description to identify an object, it searches for an object that matches all of the property values in the description.
If UFT is unable to find any object that matches the learned object description, or if it finds more than one object that fits the description, then UFT ignores the learned description and uses the Smart Identification mechanism (if defined and enabled) to try to identify the object.
Smart-Identification-Properties-UFT

Base Filter Properties

These are the most fundamental properties of a particular test object class; those whose values cannot be changed without changing the essence of the original object. For example, if a Web link’s tag was changed from “Html tag:=A” to any other value, you could no longer call it the same object.

Optional Filter Properties

Optional Filter Properties. Other properties that can help identify objects of a particular class.
These properties are unlikely to change on a regular basis but can be ignored if they are no longer
applicable.

Visual Relation Identifiers (VRI) in UFT

Visual Relation Identifier also called VRI is a new feature in UFT that identifies an object using its relative location, relation, and distance from neighboring objects. To know more about the Visual Relation Identifier please refer to my post How to Use Visual Relation Identifier in UFT with Example.

Recommended Posts

Leave a Reply