Object Identification mechanism
In Automation testing, you hear the word ‘OBJECT’ many times. So, what is an object?
Object: From automation perspective, whatever you see in an Application like Browser,Page,button,Textbox,Link,Radio button,check box etc. are called as Objects.
Now, an automation engineer’s task is to perform some operation on these objects like enter data into text box,click on button etc. For that, these object should be identified through our script. The approach used for identifying these object is called ‘Object Identification’.
An object is identified on the basis of a set of properties and values which helps to recognized that object uniquely in AUT. Every object will have a combination of properties and values.How does it work? Let’s see with an example.
Suppose,Your friend requested you to bring out his car from the parking lot. He has given you the description of the car like car’s color is red,company name,model no and car registered number. You have stored all these description(properties) in your mind and easily identified the car.
After one month, you and your friend has decided to go out for a party in his car. But in parking lot, there are 2 more car parked beside his car of the same company and color. Just for fun, Your friend asked you to recognize his car. You started observing all the 3 cars to identify the correct one.You observed that you can not go with the company name ,model no or color. Because all cars are having the same properties, so look exactly same. Now,You try to identify some other way and you observed the car number carefully and recalled that your friend’s car number was very unique which was ending with 888.Out of all the cars, now, you have easily identified the right car with the number ending with 888.
Car also had some properties and values.
Properties Values
Vehicle type Car
Color Red
Company name XYZ so on..
In the same way, each test object has some properties and values which is stored in object repository and UFT try to identify the run time objects with these properties in Application.
Test Object: The objects stored in the object repository with its properties and values.
Run time Object: The objects in Application that UFT tries to identify during run time.
There are 2 type of properties.
1. Mandatory Properties: As its name says, these are the mandatory properties which are considered on priority when we record on the objects or add the objects in OR manually.When these properties are used to identify the object at run time,all mandatory and assistive properties are used together for identification.
2. Assistive Properties: After mandatory properties , these properties are used for object identification.
What if, Mandatory and assistive properties are not enough to identify the object?
If UFT is unable to identify the object with the combination of mandatory and assistive properties. Then UFT goes for another in-built mechanism called ‘Smart Identification’.
Smart identification has optional feature. It depends on the tester whether use it or not during run time execution.
This option is available in the Test object details in object repository for a particular object. We can make it false or true depending on the requirement. Or we can set it globally as well by going into the menu ‘Tools–> Object Identification’ . There is a check box provided for smart identification. If we uncheck it , Smart identification will be disabled globally for those type of objects.
Smart identification mechanism:
It has 2 type of properties.
1. Base filter properties : These are the fundamental properties of a test object class whose values cannot be changed unless essence of the original object is changed.
2. Optional filter properties: These properties cannot be changed on a regular basis, but can be ignored if they are no longer applicable.
During smart identification, UFT use both of these properties and pick one by one from base filter porperties first and then from optional filter properties. In this way, It creates a candidate list which is used to identify the object even though object’s learned properties (mandatory and assistive) have been changed. If it is able to create a unique candidate list which is able to identify the object.
In practical scenario, we should avoid using it because if it is enable and identifying the object. So, we will never come to know if there is change in mandatory properties. We should go for mandatory and assitive properties for stability of the scripts. Or sometimes, it may recognize the undesired object which is having same kind of object description.
If both the concepts does not work, then what?
There are something called ‘Ordinal identifier’. Ordinal identifier are of 3 types.
Ordinal Identifier:
1. Index: Index tells the position of the objects in the application code. Index start from zero(0). Suppose, there are 4 identical text boxes on any page which are having exact same properties and we need to enter some text into 3rd one. Then index will be useful as their index will be assigned to them like 0,1,2,3 respectively. So, in our case, 3rd text box will be identified with the index 2.
2. Location: Location will also tell the position of the object but relative to the parent window.It also start with zero(0).
3. CreationTime: This is used only for browser identification. Suppose, we have 4 browser opened with the same application. Consider Gmail application. Now, we need to enter the gmail username in 2nd browser. In this case, we have to use ‘CreationTime’ as 1 to work with the second browser.