Skip to main content

Smart Indentification in QTP

Smart Identification in QTP : :
QTP has a unique feature by the name Smart Object Identification or recognition which is used for identifying the objects smartly, whenever the normal identification fails due to the dynamic changes in the properties of the objects.
Smart identification is a technique in QuickTest Professional. It is used to identify the objects, even though few mandatory properties are changed at run time. Smart Identification is nothing but an algorithm used by the QTP when it is not able to recognize an object.
A simple generic example as per the QTP manual would be, A photograph of a 8 year old girl and boy and QTP records identification properties of that girl when she was 8, now when both are 10 years old then QTP would not be able to recognize the girl. But there is something that is still the same that is there is only one girl in the photograph. So a kind of PI - Programmed intelligence is needed instead of AI.

Note:-
- Smart Identification is not Artificial Intelligence
- SI uses loose/unreliable object recognition
- It’s recommended to disable SI for each and every page/window/control using the Tools->Object Identification dialog (Recording).
Object identification is necessary to recognize the GUI objects on the screen. During automatic recording of a script, the object identifier records various objects present on the screen. The smart identification feature of QTP smartly identifies all the objects irrespective of their being developed using same technology or not, e.g. smart identification shall be able to identify the objects in an application although developed in Java but using some of the Microsoft controls as well.
QTP identifies a particular object by comparing the properties of its test object and the run time object. QTP may not be able to recognize any dynamic objects whose properties or even the description may undergo some changes during the run time. Thus its great option of enabling Smart Identification helps us in identifying the objects even if their properties have undergone changes during the run time.
If QTP is not able to detect any object having description matching with that of the recorded object, or in case it detects more than one object having matching description, then QTP ignores the recorded description, and uses the Smart Identification feature to identify the object. Smart Identification mechanism is a bit complex, but flexible. However, if configured logically, Smart Identification definition can help QTP in detecting an object, of course - if present, in-spite of failure of the recorded description.

Understanding and Configuring Smart Identification in QTP : :

When QuickTest uses the learned description to identify an object, it searches for an object that matches all of the property values in the description. In most cases, this description is the simplest way to identify the object, and, unless the main properties of the object change, this method will work.
If QuickTest is unable to find any object that matches the learned object description, or if it finds more than one object that fits the description, then QuickTest ignores the learned description, and uses the Smart Identification mechanism to 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 QuickTest 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 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 QuickTest activates the Smart Identification mechanism during a run session (because it was unable to identify an object based on its learned description), it follows the following process to identify the object:
QuickTest "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.
QuickTest 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.

QuickTest evaluates the new object candidate list:

If the new object candidate list still has more than one object, QuickTest 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, QuickTest 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 QuickTest concludes that it has identified the object and performs the statement containing the object.
QuickTest 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, QuickTest still cannot identify the object, then QuickTest 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 QuickTest stops the run session and displays a Run Error message. For more information on Run Error messages, see Troubleshooting QuickTest Tests.

Reviewing Smart Identification Information in the Test Results :

If the learned description does not enable QuickTest to identify a specified object in a step, and a Smart Identification definition is defined (and enabled) for the object, then QuickTest tries to identify the object using the Smart Identification mechanism.
If QuickTest successfully uses Smart Identification to find an object after no object matches the learned description, the step is assigned a Warning status in the Test Results, and the result details for the step indicate that the Smart Identification mechanism was used. If the Smart Identification mechanism cannot successfully identify the object, QuickTest uses the learned description plus the ordinal identifier to identify the object. If the object is still not identified, the test or component fails and a normal failed step is displayed in the results.

EG :...

The following example walks you through the object identification process for an object. Suppose you have the following statement in your test or component:
Browser("Mercury Tours").Page("Mercury Tours").Image("Login").Click 22,17
When you created your test or component, QuickTest learned the following object description for the Login image:
Figure : 1
However, at some point after you created your test or component, a second login
button (for logging into the VIP section of the Web site) was added to the page,
so the Web designer changed the original Login button's alt tag to: basic login.
The default description for Web Image objects (alt, html tag, image type)
works for most images in your site, but it no longer works for the Login image,
because that image's alt property no longer matches the learned description.
Therefore, when you run your test or component, QuickTest is unable to identify
the Login button based on the learned description. However, QuickTest succeeds
in identifying the Login button using its Smart Identification definition.
The explanation below describes the process that QuickTest uses to find the Login
object using Smart Identification:

1. According to the Smart Identification definition for Web image objects,
QuickTest learned the values of the following properties it learned the
Login image:
Figure : 2
The learned values are as follows:

Base Filter Properties:
Figure : 3
Optional Filter Properties:
Figure : 4
2. QuickTest begins the Smart Identification process by identifying the five
objects on the Mercury Tours page that match the base filter properties
definition (html tag = INPUT). QuickTest considers these to be the object
candidates and begins checking the object candidates against the
Optional Filter Properties list.
3. QuickTest checks the alt property of each of the object candidates, but
none have the alt value: Login, so QuickTest ignores this property and
moves on to the next one.
4. QuickTest checks the image type property of the each of the object
candidates, but none have the image type value: Image Button, so
QuickTest ignores this property and moves on to the next one.
5. QuickTest checks the name property of each of the object candidates, and
finds that two of the objects (both the basic and VIP Login buttons) have
the name: login. QuickTest filters out the other three objects from the list,
and these two login buttons become the new object candidates.
6. QuickTest checks the file name property of the two remaining object
candidates. Only one of them has the file name login.gif, so QuickTest
correctly concludes that it has found the Login button and clicks 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
Figure : 5
2. Select the appropriate environment in the Environment list. The test
object classes associated with the selected environment are displayed in
the Test object classes list.
Note: The environments included in the Environment list are those that
correspond to the loaded add-ins. For more information on loading addins,
see the section on loading QuickTest add-ins in the HP QuickTest
Professional Add-ins Guide.
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.
Figure : 6
5. In the Base Filter Properties list, click Add/Remove. The Add/RemoveProperties dialog box for base filter properties opens.
Figure : 7
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.
You can specify a new property by clicking New and specifying a valid
property name in the displayed dialog box.
Tip: You can also add property names to the set of available properties for
Web objects using the attribute/ notation. To do this,
click New. The New Property dialog box opens. Enter a valid property in
the format attribute/ 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.
Figure : 8
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.
You can specify a new property by clicking New and specifying a valid
property name in the displayed dialog box.
Tip: You can also add property names to the set of available properties for
Web objects using the attribute/ notation. To do this,
click New. The New Property dialog box opens. Enter a valid property in
the format attribute/ and click OK. The new property is
added to the Optional 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.
Figure : 9
11. Use the up and down arrows to set your preferred order for the optional
filter properties. When QuickTest 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.




Comments

Popular posts from this blog

Convert JSON to XML using QTP/UFT/VBScript

Sample Code : Dim strPage,strJSON,objIE strPage = "C:\Jay\JLoader.html" Set objIE = CreateObject("InternetExplorer.Application") objIE.Visible = True objIE.Navigate2 strPage While objIE.Busy : Wend strJSON = "{""FirstName"":""Jay"", ""LastName"":""Krishna""}" Set objWin = objIE.document.parentWindow objWin.execScript "var jsonStr2XML = function(strJSON) { return json2xml(JSON.parse(strJSON));};" Msgbox  oWin.jsonStr2XML(strJSON) objIE.Quit In Detail: Converting The most popular data interchange format JSON(JavaScript Object Notation) to XML using QTP/UFT. Parsing JSON in UFT could be a challenge so we will use JavaScript in UFT to make it perfect. SO We need :              Java Script API  - To Convert JSON to XML                         JavaScript Files :                         http://goessner.net/download/prj/jsonxml/j

Read Outlook mail attachment and Body using Vb Script or QTP

Set olApp = CreateObject("Outlook.Application") Set olns = olApp.GetNameSpace("MAPI") Set ObjFolder = olns.GetDefaultFolder(6) j = 0 For each item1 in ObjFolder.Items        iattachCnt = item1.Attachments.Count     Print "Attachments Count: " & iattachCnt     For i = 1 to iattachCnt         Print "FileName :    " & item1.Attachments(i).FileName         Print "Display Name:   " & item1.Attachments(i).DisplayName         Print "Size: " & item1.Attachments(i).Size     Next     Print " Body : " & item1.body     Print "--------------------------------------Mail Num - " & j & " -----------------------------------------------"     j = j+1    Next

Excel Sorting By Rows and Columns

Excel Sorting By Row: Const xlAscending = 1 Const xlNo = 2 Const xlSortRows = 2 Set objExcel = CreateObject(“Excel.Application”) objExcel.Visible = True Set objWorkbook = objExcel.Workbooks.Open(“C:\Jay\Docs1.xls”) Set objWorksheet = objWorkbook.Worksheets(1) objWorksheet.Cells(1,1).activate Set objRange = objExcel.ActiveCell.EntireRow objRange.Sort objRange, xlAscending, , , , , , xlNo, , , xlSortRows set objExcel=nothing Excel Sorting By Column : Const xlAscending = 1′represents the sorting type 1 for Ascending 2 for Desc Const xlYes = 1 Set objExcel = CreateObject(“Excel.Application”)’Create the excel object objExcel.Visible = True’Make excel visible Set objWorkbook = _ objExcel.Workbooks.Open(“C:\Jay\Docs1.xls”)’Open the document Set objWorksheet = objWorkbook.Worksheets(1)’select the sheet based on the index .. 1,2 ,3 … Set objRange = objWorksheet.UsedRange’which select the range of the cells has some data other than blank Set objRange2 = objExcel.Range

How to Read or Select Context Menu or Right Click Menu using QTP.

Select The Item in Right Click Menu or Context Menu: Window("sampleWindow").WinMenu("MenuObjType:=1).Select"File;New" Here MenuObjtype can be 1 r 2 r 3 .......n Check wether the Item is Exist or Not: If Window("sampleWindow").WinMenu("MenuObjType:=1).GetItemProperty("1","Exist") Then   Msgbox"Exist" Else  Msgbox"Does Not Exist" End If                                         Or If Window("sampleWindow").WinMenu("MenuObjType:=1).GetItemProperty("File","Exist") Then   Msgbox"Exist" Else  Msgbox"Does Not Exist" End If Get the Items in Context Menu: For i = 1 to 10 Print  Window("sampleWindow").WinMenu("MenuObjType:=" & i).GetItemProperty("1","Label") Then Next

How to Download a file using VbScript

Following is the code to download a file using Vbscript, without using QTP This code uses the HTMLDom and URLDownloadToFile method from urlmon API. Since VBScript does support calling Native API methods directly, here I am using  Excel macro to declare a function for the urlmon API and running the macro by Excel API from VBscript Step1: Create a new excel and open the visual basic editor, Insert Module and paste the following code the Module, save the excel file Private Declare Function URLDownloadToFile Lib “urlmon” Alias _                                            “URLDownloadToFileA” ( _                                            ByVal pCaller As Long, ByVal szURL As String, _                                            ByVal szFileName As String, _                                            ByVal dwReserved As Long, _                                            ByVal lpfnCB As Long) As Long Sub FileSave(strUrl, Des)     r = URLDownloadToFile(0, strUrl, Des, 0, a)