Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE
Highlighted
Absent Member.. MisterT1968 Absent Member..
Absent Member..
212 views

[QTP/(U)FT Support Tip]: Can the Smart Identification be disabled using code?

Hello all,

 
How are you? I hope you are fine

 
Sometimes, it is necessary to switch off the Smart identification. As QuickTest Professional Smart identification setting is a test level setting, the issue may arise, that if it was enabled earlier for a script and later needs to be disabled, you either need to use QTP AOM (Automation Object Model) or you need individually go and disable smart identification in each script.

 
The suggestions below demonstrates a way to disable smart identification in the scripts:
 
Disable smart identification

 
Setting("DisableReplayUsingAlgorithm") = 1

 
or using AOM code

 
CreateObject("QuickTest.Application").Test.Settings.Run.DisableSmartIdentification = True

 
Enable smart identification

 
Setting("DisableReplayUsingAlgorithm") = 0

 
or using AOM code

 

CreateObject("QuickTest.Application").Test.Settings.Run.DisableSmartIdentification = False 

 
The code above should be added to an associated library file so that it can apply to the whole test

 
If you prefer to change the smart identification object-wise, including object properties, you can check the QTP help, by searching “Enable Smart Identification”. To avoid inconvenience an example is posted here:

 

 
************************************************************************************************************************
'Description:
'
'This example opens QuickTest and configures the Object Identification settings for the WinList test object class.
'************************************************************************************************************************

 
Dim qtApp 'As QuickTest.Application ' Declare the Application object variable
Dim qtIdent 'As QuickTest.ObjectIdentification ' Declare the ObjectIdentification object variable
Dim qtWinListIdent 'As QuickTest.TestObjectClassIdentification ' Declare the variable for the WinList object class identification
Dim intPosition ' Declare a variable for storing positions

 
' Open QuickTest and set variables

Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object

qtApp.Launch ' Start QuickTest
qtApp.Visible = True ' Make the QuickTest application visible

 
Set qtIdent = qtApp.Options.ObjectIdentification ' Return the ObjectIdentification object
Set qtWinListIdent = qtIdent.Item("WinList") ' Return the collection of object identification properties for the WinList object class

 
qtIdent.ResetAll ' Reset the Object Identification description for the WinList object to the default property set
qtWinListIdent.OrdinalIdentifier = "Index" ' Set Index as the ordinal identifier

 
' Configure the Mandatory Properties

intPosition = qtWinListIdent.MandatoryProperties.Find("nativeclass") ' Find the location of the "nativeclass" mandatory property

qtWinListIdent.MandatoryProperties.Remove intPosition ' Remove the "nativeclass" mandatory property from the list
If qtWinListIdent.AvailableProperties.Find("items count") <> -1 Then ' If "items count" is an available identification property for WinList
  qtWinListIdent.MandatoryProperties.Add "items count" ' Add it as a mandatory property
End If

 
' Configure the Assistive Properties

qtWinListIdent.AssistiveProperties.RemoveAll ' Remove all assistive properties
qtWinListIdent.AssistiveProperties.Add "all items" ' Add the "all items" property as an assistive property
qtWinListIdent.AssistiveProperties.Add "width", 1 ' Add "width" as the first assistive property
qtWinListIdent.AssistiveProperties.Add "height", -1 ' Add "height" as the last assistive property
qtWinListIdent.AssistiveProperties.MoveToPos 2, 1 ' Move the second assistive property (currently "all items") to the first position in the list

' Configure the Smart Identification

qtWinListIdent.EnableSmartIdentification = True ' Enable the smart identification mechanism for the WinList object
If qtWinListIdent.BaseFilterProperties.Count = 0 Then ' If there are no Base Filter properties
  qtWinListIdent.BaseFilterProperties.Add "x" ' Add the "x" property as a base filter property
  qtWinListIdent.BaseFilterProperties.Add "y" ' Add the "y" property as a base filter property
End If

qtWinListIdent.OptionalFilterProperties.Add "abs_x", 1 ' Add "abs_x" as the first optional filter property
qtWinListIdent.OptionalFilterProperties.Add "abs_y", 2 ' Add "abs_y" as the second optional filter property

 
Set qtWinListIdent = Nothing ' Release the WinList identification object
Set qtIdent = Nothing ' Release the ObjectIdentification object
Set qtApp = Nothing ' Release the Application object

 
As you may know, Smart Identification is Object Repository dependent, so if you intend to use Descriptive Programming, Smart Identification will not be triggered.

 
I hope these information help.

 
Best regards,

Tino Pacholski

Functional Testing Support Engineer

[If this post solves or helps solve your issue, mark the thread as solved and give KUDOS to the author for their assistance.]
Labels (2)
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.