Blog to understand automation concepts in QTP, Selenium Webdriver and Manual Testing concepts

Learning Object Identification in UFT/QTP with Question and Answers

In this topic we will discuss in detail various questions on object identification with expectation that it covers and help reader understand the concepts of Object Identification with these topics:

Question 1: What are the objects identified in QTP?

Answer: When we record or learn object in QTP, QTP records properties of the object known as identification properties which are specific to the object class, for e.g. when we identify an input box, it is an object of WebEdit class and will store specific properties to the object. These objects are known as Test Objects.

When we run a test in QTP, QTP matches properties stored for test objects with run-time objects, i.e. objects in the application during test run. If the properties of run time object matches with test objects, we can perform operations on the identified object.


Question 2: What are native properties and Identification properties?

Answer: Identification Properties are properties that QTP uses to identify objects in application. The identification properties for a test object are determined by its test object class and values for properties are used to identify object.

We can retrieve and set test objects and properties using GetTOproperty and SetTOproperty. GetTOproperty method retrieves the property of object as stored in repository whereas SetTOproperty sets the property value of a test object in repository. Similar to this, GetROproperty is used to retrieve property of runtime object. Since we cannot change property of an object at runtime, there is nothing like SetROProperty

Browser("google").Page("google").WebEdit("UserName").SetTOProperty "Name", "Nitin"
strName= Browser("google").Page("google").WebEdit("UserName").GetTOProperty("Name")
strName= Browser("google").Page("google").WebEdit("UserName").GetROProperty("Name")

Native properties are properties as created by the creator of object, e.g. Microsoft is creator for IE explorer objects. We can retrieve native properties value for an object using .object

e.g. : Set objReport = Browser("Google").Page("title:=.*").Frame("name:=ifrt5").Object.getelementbyid("username")
objReport.innertext = “nitin”
This code will search for element with html id as “username” in frame object and sets value nitin in the element.


Question 3: How is an object identified in QTP?

Answer: 
1. UFT first identifies an object based on description properties, and if no match is found, it throws an error. In case unique match is found, QTP perform action of the matched object.
2. If multiple matches are found based on description properties, and Visual Relation Identifier (Identifying object based on relative position of an object w.r.t other objects) is defined for test object, QTP searches for a match based on the relational identifier.
3, In case 1) and 2) does not result in a unique match for object, QTP Searches for an object using smart identification.
4. In case, step 1, 3) does not return a unique matching object and Visual Relation Identifier is not defined, QTP looks for ordinal identifier.
Ordinal identifiers are not used in case visual relation identifiers are defined for object.


Question 4: What are description properties?

 Answer: For every test object, there are identification properies by which QTP identifies the object. 
Properties that QTP always learns as part of the description for test objects of the selected class are called mandatory property, in case object is not identified uniquely during learning or recording, QTP learns additional properties for test object of the selected class to create a unique test object description. These additional properties are known as Assistive properties. Assistive and mandatory properties used together to learn an object during learn or recording are known as Description properties.


Question 5: Can we modify which properties to be learned as mandatory and which to be learned as assistive properties?

Answer: By default in QTP, for each test object class, there are certain properties which are defined as mandatory properties and some other properties as Assistive properties, but we can change the properties to be learned as mandatory or assistive as described below:

Navigate to Tools>Object Identification in UFT 11.5.  In the Object Identification window, for each object class there are properties marked as mandatory and assistive, we can add remove properties using add/remove button as shown below:
Defining mandatory and assistive properties

Question 6: What is Smart Identification?

Answer: When an object is not uniquely recognized by the description properties and visual relation identifier defined for object, QTP uses smart identification mechanism to uniquely identify an object if smart identification is set as true at object properties in the object repositories. There are some set of properties known as base filter properties (most fundamental properties of a particular test object class) and optional filter properties (additional properties that can help identify objects of a particular class.).
Smart Identication properties
Smart identification process is as follows:
QTP unlearns all the properties defined for object.
Based on first base filter properties, QTP shortlists all the objects within the same parent class,
QTP further shortlists based on other base filter properties followed by optional filter properties until a unique match for object is found. In case no unique match is found, post short listing by all optional filter properties, QTP selects unique object based on ordinal identifier defined for object.

Question 7: What is the default ordinal identifier for web browser object?

a.  Creation Time
b.  Location
c.  Index
d.  Position.
Answer: The default ordinal identifier is Creation time for browser object, for all other web object, the default ordinal identifier is Index.For Standard Windows object, it is Location.

Please add any additional information that needs to be covered in topic on object Identification. Object Repository will be discusses in detail in another Question and Answer article


3 comments:

  1. Why smart identification has to be disabled in some scenarios?

    ReplyDelete
    Replies
    1. Smart Identification is the first attempt to filter out the matches when description and visual identifiers do not produce unique hit. Only when smart identification does not lead to unique match, ordinal identifiers are checked. There may be case when you know that filter properties do not lead to unique match. In those cases if you disable smart identification, it will directly look at ordinal identifiers there by speeding up the process.

      Delete