Sunday, 21 September 2014

QTP - Smart identification

If the recorded description does not enable QTP to identify a specific object then QTP uses “Smart identification” mechanism.  It uses the following additional properties to identify the object
a) Base Filter Properties (primary) – The set of properties that cannot be changed without changing the object type
b) Optional Filter Properties (secondary) – additional properties that help identify the object uniquely.

Assume a situation when no object matches or multiple objects match the recorded description for an object during run time, how does QTP handle it?
QTP has a mechanism in place for cases exactly like this. If the recorded description does not enable QTP to identify the specified object in a step, and a smart identification definition is defined (and enabled) for the object, QTP tries to identify the object using “Smart identification”.
Let us see how this works with some examples.  For every object there are Primary Properties and Secondary properties.
Example 1: Object with the recorded description is not found.
On a page there was a button and the following are properties:
a) Primary: Name
b) Secondary: Abs x,y
While recording the “Name” property was “Login ID”. Due to some changes to the application, the “Name” property is now changed to “User ID”. In this case, QTP will find a button with a different description and it should fail if it considers the primary properties alone.
But in cases like this when the primary properties don’t match then it checks the secondary ones and if they match it recognizes the object. In this case, it is going to recognize the button by its X and Y co-ordinates.
Example 2: QTP was supposed to find a page X and there are 2 pages with similar browser settings.
In this case too, it tries to use the “name” or other properties to find the right page/pages and works accordingly.
The above 2 are examples of cases where QTP engages the smart identification mechanism.
  • The Test results will also show if a step employed Smart identification to run successfully.
  •  If QTP cannot find the object despite Smart Identification, then the test fails.
For most of the objects, QTP provides a default Base filter properties (Primary) and Optional filter properties (Secondary) that it checks if we enable Smart identification for them. The user does have an option to edit what properties to consider too. To do so, go to “Tools->Object Identification”. Choose the relevant Environment from the drop down and choose the Object Class. Once you chose it, check the “Enable Smart Identification” and click “Configure”.
Smart identification
Click Add or Remove
Smart identification
Select the properties as required:
Smart identification
Make your selection and Click OK when done.
Smart identification
The above process will ensure that the next time it has difficulty identifying an object of this class, it will employ smart identification to do so.
Also, for most of the objects “Smart identification” is turned ON by default. You can see where this is the case for a certain object by accessing it in the OR under “Additional details” part of its object properties.
It is set to “True” if enabled and “False” if disabled.
You could also choose to enable or disable Smart identification entirely for a test run. Choose “File->Settings->Run->Disable Smart Identification during the run session” option.

No comments:

Post a Comment