http://quicktesthp.blogspot.com

QTP VBScript new series + Interview Question Bank on QTP for enrichment of Knowledge in QTP

This Site has been brought to you by HP Certified Expert of QTP.

Exciting new articles for October:

1) QTP Tip:Deselect all Radio Buttons

2) HP QTP Crypt Object

3)Adding Hyperlinks in Excel Spreadsheet

Best of Luck Friends ! ! !

Expert QTP
expert.qtp@gmail.com

All Articles are Copyright Protected. These are Free for Reading & Personal Use. Reproduction in Any Form without the Permission is Illegal & Strictly Prohibited.

Copyright © 2009 ExpertQTP

Google Search

Friday, August 8, 2008

Smart Identification: A Fantastic Feature of 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 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.

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 the Smart Identification Process: (Ref. Quick Test Professional 9.0 – Help Guide)

If QTP 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:

1) QTP "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) QTP 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) QTP evaluates the new object candidate list:

# If the new object candidate list still has more than one object, QTP 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, QTP 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 QTP concludes that it has identified the object and performs the statement containing the object.

4) QTP 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, 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.

How to Analyze Smart Identification Information displayed in the Test Results?
(Ref. Quick Test Professional 9.0 – Help Guide)

If the recorded description does not enable QTP to identify the specified object in a particular step, and a Smart Identification definition is defined (and enabled) for the object, then QTP tries to identify the object using the Smart Identification mechanism. There are two possible scenarios.

Scenario –1: No Object Matches the Recorded Description

If QTP happens to successfully use the Smart Identification feature to recognize an object after no object found to match with the recorded description, the Test Results receive a warning status by providing the information like the following in the results details:

1) An indication that the object (for example, the userName WebEdit object) was not found.

2) An indication that the Smart Identification mechanism successfully found the object, and information about the properties used to find the object. You can use this information to modify the recorded test object description, so that QTP can find the object using the description in future run sessions.

3) Normal result details for the performed step.

The following screenshot displays the results for a test in which Smart Identification was used to identify the userName WebEdit object after one of the recorded description property values have changed.


Scenario –2: Multiple Object Match the Recorded Description

If QTP happens to successfully use the Smart Identification feature to recognize an object after multiple objects have been found to match the recorded description, QTP shows the Smart Identification information in the Test Results window. The step still receives a ‘Passed’ status, because in most of the cases, if Smart Identification was not used, the test object description plus the ordinal identifier could have potentially identified the object. In such a situation, the Test Results shows information like the following in the results details:

1) An indication that the Smart Identification mechanism has successfully found the object, and information about the properties used to find the object.

This information can be used to create a unique object description for the object, so that QTP can find the object using this description in the future run sessions.

2) Normal result details for the performed step.

The following screenshot displays the results for a test in which Smart Identification was used uniquely identifies the Home object after the recorded description resulted in multiple matches.


If the Smart Identification mechanism cannot successfully identify the object, the test fails and a normal failed step is displayed in the Test Results.

Smart Identification Feature of QTP uses two types of properties:


a) Base filter properties: Are the most fundamental properties of a particular test object class. Her we can not change their values without changing the essence of the original object.

b) Optional filter properties: Are other properties, which help us in identifying the objects of a particular class since these are not likely to get changed frequently. These properties can be ignored in case these are not applicable any more.

Smart Identification Example: (Ref. Quick Test Professional 9.0 – Help Guide)

The object identification process for an object is described through the following example in great detail.

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, QTP learned the following object description for the Login image:


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, QTP is unable to identify the Login button based on the learned description. However, QTP succeeds in identifying the Login button using its Smart Identification definition.

The explanation below describes the process that QTP uses to find the Login object using Smart Identification:

1) According to the Smart Identification definition for Web image objects, QTP learned the values of the following properties when you recorded the click on the Login image:


The learned values are as follows:

Base Filter Properties:
_____________
Property Value
______________
html tag INPUT
______________

Optional Filter Properties:


2) QTP 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 and image type = Image Button). QTP considers these to be the object candidates and begins checking the object candidates against the Optional Filter Properties list.

3) QTP checks the alt property of each of the object candidates, but none have the alt value: Login, so QTP ignores this property and moves on to the next one.

4) QTP 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. QTP filters out the other three objects from the list, and these two login buttons become the new object candidates.

5) QTP checks the file name property of the two remaining object candidates. Only one of them has the file name login.gif, so QTP correctly concludes that it has found the Login button and clicks it.

How to Disable Smart Identification During the run Session:


Selection of the option “Disable Smart Identification during the run session”, Instructs QTP not to use the Smart Identification mechanism during the run session.

When we select this option, the Enable Smart Identification check boxes in the Object Properties and Object Repository dialog boxes get disabled, although the settings are saved. However when you clear this option, the Enable Smart Identification check boxes return to their previous on or off setting.

When should we use Smart Identification feature of QTP?

As per the suggested best practice we should disable Smart Identification while creating the test cases, so that we are able to recognize the objects which are dynamic or inconsistent in their properties. Moreover once the script gets created, the Smart Identification should be enabled, so that the script does not fail in case of any small change.

However the scriptwriter should always check for the test results to verify if the Smart Identification feature had been used to identify a object or not. Sometimes Smart Identification needs to be disabled for particular objects in the OR, this is advisable when you use SetTOProperty to change any of the TO properties of an object and especially ordinal identifiers like index, location and creation time.

Keywords: QTP, quicktest, hp, qtp smart identification

No comments:

 
Copyright © 2009 ExpertQTP