How does QTP identify objects?
This is the very basic question that normally comes in everyone’s mind, So In today’s post I am going to explain about How QTP identifies or recognizes the object.
As you all are aware that all the objects are stored in Object Repository (OR).
Let’s take one simple example to understand the QTP indentifying concept in a better way, following is the one sentence recorded by QTP which clicks on “Google Search” button on Google home page.
Browser(” Google “).Page(“Google”).WebButton(“Google Search”).Click
Now you can see in below figure that object named “Google Search” is stored in OR and its parent object is “Google”.
QTP identifies the object mainly based on two following properties.
1. Mandatory Property
2. Assistive Property
In right bottom side, you can see Description properties for Google parent object, for “Google Search” child object the description properties can be following,
1. Name = Web Search
2. HTML tag = INPUT
3. Type = Submit
Now, For “Google Search” web button the Mandatory properties are “Name” and “HTML tag”, these two properties are enough to identify the object. If QTP fails to identify the objet than Assistive Property will come in to picture. For “Google Search” object “Type” is one of the assistive properties.
Normally using Mandatory and Assistive property QTP identifies the object.
Now, let’s assume one scenario where the same object (Google Search) appears at two different areas on the same webpage. Will QTP still able to identify the object? Yes you guess right!!! QTP again fails to recognize the object. In such situation Ordinal identifier play the crucial role to identify the object. During recording itself QTP assigns index to 0 for first object and index to 1 for second object. Thus, in this way QTP recognize the two different objects having same properties.
At last if nothing works than QTP uses Smart Identification method to recognize or identifies the object in QTP. This mechanism uses base filter properties or optional filter properties to identify the object in QTP whenever normal identification using Mandatory and assistive properties fails because of runtime changes in properties of object.