Object Identification is the core of UFT. You should understand it thoroughly before you try to work on any automation testing projects. In the earlier tutorial we discussed the complete object identification process in UFT. We discussed various stages of object identification namely Learned Description, Visual Relation Identifiers (VRI), Smart Identification and Ordinal Identifiers. In this tutorial, we will discuss the 3rd stage in detail – Smart Identification

What is Smart Identification?

If UFT is unable to identify any object that matches the learned object description, or if it finds more than one object that fits the description, then UFT ignores the learned description, and uses Visual Relation Identifiers (VRI) to identify an object uniquely. If VRI is not defined or VRI is not able to identify the object uniquely, UFT invokes the Smart Identification mechanism and try to identify the object.

While the Smart Identification mechanism is more complex, it is more flexible. Therefore, if configured logically, a Smart Identification definition can probably help UFT 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—The most fundamental properties of a particular test object class; those whose values cannot be changed without changing the essence of the original object. For example, if a Web link’s tag was changed from a to any other value, you could no longer call it the same object.
  • Optional Filter Properties—Other properties that can help identify objects of a particular class. These properties are unlikely to change on a regular basis, but can be ignored if they are no longer applicable.

Understanding the Smart Identification Process

If UFT activates the Smart Identification mechanism during a run session (because it was unable to identify an object based on its learned description and VRI), it follows the following process to identify the object:

  1. UFT “forgets” the learned test object description and creates a new object candidate list containing the objects (within the object’s parent object) that match all of the properties defined in the Base Filter Properties list.
  2. UFT filters out any object in the object candidate list that does not match the first property listed in the Optional Filter Properties list. The remaining objects become the new object candidate list.
  3. UFT evaluates the new object candidate list:
    • If the new object candidate list still has more than one object, UFT uses the new (smaller) object candidate list to repeat step 2 for the next optional filter property in the list.
    • If the new object candidate list is empty, UFT ignores this optional filter property, returns to the previous object candidate list, and repeats step 2 for the next optional filter property in the list.
    • If the object candidate list contains exactly one object, then UFT concludes that it has identified the object and performs the statement containing the object.
  4. UFT continues the process described in steps 2 and 3 until it either identifies one object, or runs out of optional filter properties to use.

If, after completing the Smart Identification elimination process, UFT still cannot identify the object, then there are two possibilities:

  1. If VRI IS defined: UFT pauses the run session and displays a Run Error message
  2. If VRI is NOT defined: UFT 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 UFT stops the run session and displays a Run Error message.

Reviewing Smart Identification Information in the Test Results

If the learned description and VRI does not enable UFT to identify a specified object in a step, and a Smart Identification definition is defined (and enabled) for the object, then UFT tries to identify the object using the Smart Identification mechanism.

If UFT successfully uses Smart Identification to find an object after no object matches the learned description, the Test Results receive a warning status ⚠ and indicate that the Smart Identification mechanism was used.

If the Smart Identification mechanism cannot successfully identify the object and VRI is not defined, UFT uses the learned description + the ordinal identifier to identify the object. If the object is still not identified, the test fails and a normal failed step is displayed in the results.

Walking Through a Smart Identification Example

The following example walks you through the object identification process for an object.

Suppose you have the following statement in your test:

Browser("LearnQTP").Page("LearnQTP").WebEdit("userName").Set "mercury"

When you created your test, UFT learned the following object description for the UserName edit box:

However, at some point after you created your test, a second UserName edit box was added to the bottom of the page, so the Web designer changed the original UserName edit box name tag to: userName1

The default description for edit box objects (type, name, html tag) works for most edit boxes in your site, but it no longer works for the UserName edit box, because that edit box name property no longer matches the learned description. Therefore, when you run your test, UFT is unable to identify the UserName edit box based on the learned description. However, UFT succeeds in identifying the UserName edit box using its Smart Identification definition.

The explanation below describes the process that UFT uses to find the UserName edit box object using Smart Identification:

1. According to the Smart Identification definition for WebEdit objects, UFT learned the values of the following properties when you recorded the click on the UserName edit box:

base optional filter properties

2. UFT begins the Smart Identification process by identifying the two objects on the web page that match the base filter properties definition (html tag = INPUT and type = text). UFT considers these to be the object candidates and begins checking the object candidates against the Optional Filter Properties list.

3. UFT checks the name property of each of the object candidates, but none have the name property value userName, so UFT ignores this property and moves on to the next one.

4. UFT checks the html id property of the two object candidates. Only one of them has the value loginbox, so UFT correctly concludes that it has found the first username edit box and enters the required value in it.

Step-by-Step Instructions for Configuring a Smart Identification Definition

You use the Smart Identification Properties dialog box, accessible from the Object Identification dialog box, to configure the Smart Identification definition for a test object class.

To configure Smart Identification properties:

1. Choose Tools > Object Identification. The Object Identification dialog box opens.UFT object identification dialog box

2. Select the appropriate environment in the Environment list on the top left. The test object classes associated with the selected environment are displayed in the Test object classes list.
The environments included in the Environment list are those that correspond to the loaded add-in in the Add-in Manager.

3. Select the test object class you want to configure.

4. Click the Configure button next to the Enable Smart Identification check box. The Configure button is enabled only when the Enable Smart Identification option is selected. The Smart Identification Properties dialog box opens:

Smart identification dialog box

5. In the Base Filter Properties list, click Add/Remove. The Add/Remove Properties dialog box for base filter properties opens.

smart identification base filter add remove properties

6. Select the properties you want to include in the Base Filter Properties list and/or clear the properties you want to remove from the list.
Note: You CANNOT include the same property in both the base and optional property lists.
For all environments except Web, you can specify a new property by clicking New and specifying a valid property name in the displayed dialog box.

For web objects, you can add property names to the set of available properties using the attribute/<PropertyName>  notation. To do this, click New. The New Property dialog box opens. Enter a valid property in the format  attribute/<PropertyName> and click OK. The new property is added to the Base Filter Properties list. For example, to add a property called MyColor, enter attribute/MyColor.

7. Click OK to close the Add/Remove Properties dialog box. The updated set of base filter properties is displayed in the Base Filter Properties list.

8. In the Optional Filter Properties list, click Add/Remove. The Add/Remove Properties dialog box for optional filter properties opens.

smart identification optional filter add remove properties

9. Select the properties you want to include in the Optional Filter Properties list and/or clear the properties you want to remove from the list.

Note: You cannot include the same property in both the base and optional property lists.

For all environments except Web, you can specify a new property by clicking New and specifying a valid property name in the displayed dialog box.

For web objects, you can add property names to the set of available properties using the attribute/<PropertyName>  notation. To do this, click New. The New Property dialog box opens. Enter a valid property in the format  attribute/<PropertyName> and click OK. The new property is added to the Base Filter Properties list. For example, to add a property called MyColor, enter attribute/MyColor.

10. Click OK to close the Add/Remove Properties dialog box. The properties are displayed in the Optional Filter Properties list.

11. Use the up and down arrows to set your preferred order for the optional filter properties. When UFT uses the Smart Identification mechanism, it checks the remaining object candidates against the optional properties one-by-one according to the order you set in the Optional Filter Properties list until it filters the object candidates down to one object.

That’s all about Smart Identification in UFT (QTP). In the next tutorial we will learn in detail about Visual Relation Identifier.

If you have any questions around Smart Identification, please comment below. You can refer earlier tutorials in the series at this link UFT Tutorials.

If you have not already done so, make sure you enter your name and address below to receive the next tutorial as soon as it is ready.

In case you are starting out with UFT and want an overview, check this article on What is UFT?

If you want to keep track of further articles on UFT (QTP). I recommend you to subscribe by Email and have new UFT articles sent directly to your inbox.

Subscribe to get free updates on UFT!

LearnQTP is the most popular site on UFT (formerly QTP).

Enter your first name and email address below to instantly subscribe and download an eBook on Optimizing UFT Scripts. In future, we will make sure you get new tips & tricks on UFT delivered direct to your email box.

Please check your email and confirm free subscription!