Monday, October 22, 2007

Object Identification Mechanism

QTP identifies the objects by mandatory properties set as default. If the mandatory property values are not sufficient to uniquely identify an object in the Application Under Test (AUT), QTP adds some assistive properties and/or an ordinal identifier in order to create a unique description.

The default Mandatory, Assistive Properties and Ordinal Identifiers can be changed for a specific Class of objects in QTP at Tools -> Object Identification.

The Smart Identification can also be enabled to ensure more comprehensive object identification. The User defined Class of Objects can be mapped to the standard class of Objects so that QTP identifies the user defined objects as standard objects.

What is Smart Identification?

QTP makes use of the special feature Smart Identification when it  fails to identify objects using the defined properties finds an ambiguity in identifying objects. 

The Smart Identification mechanism is more complex and more flexible. If configured logically, a Smart Identification definition can probably help QTP identify an object, if it is present, even when the learned description fails.

The Smart Identification mechanism uses two types of properties, Base Filter Properties and Optional Filter Properties.

Base Filter Properties: The most fundamental properties of a particular test object class; those whose values will not be changed. E.g. html tag = <A> for a object of Link Class

Optional Filter Properties: Other properties that can help identify objects of a particular class.

Smart Identification Process

The QTP follows the below process to identify the objects using Smart Identification Mechanism:

  1. QTP creates a new object candidate list within the Objects Parent Object containing all the objects that match all of the properties defined in the Base Filter Properties list.
  2. New Object Candidate List (OCL) is created by filtering out the objects in the OCL that does not match the first property listed in the Optional Filter Properties list.
  3. The OCL is evaluated in the following manner:
    1. If the new object candidate list still has more than one object, QTP uses the new (smaller) OCL to repeat elimination process for the next optional filter property in the list.
    2. If the new object candidate list is empty, QTP ignores this optional filter property, returns to the previous object candidate list, and repeats the elimination process for the next optional filter property in the list.
    3. If the object candidate list contains exactly one object, then QTP concludes that it has identified the object and performs the statement containing the object.
    4. QTP continues the process described above until it either identifies one object, or runs out of optional filter properties to use.

Summary

  • QTP Identifies the Object using the learnt description.
  • If unable to identify the objects using learnt description Smart Identification is invoked.
  • If after completing the Smart Identification elimination process, QTP still cannot identify the object, then QTP uses the learned description plus the ordinal identifier to identify the object.
  • If the combined learned description and ordinal identifier are not sufficient to identify the object, then QTP stops the run session and displays a Run Error message.