Wednesday 19 June 2013

Object Identification in QTP




Overview:
Generally for every object 20-25 properties information available, qtp recognizes object using 2 0r 3 important properties.

Qtp has default object identification configuration for every environment, if we feel that config is not sufficient for recognizing objects in our application, we can configure some more

Object Identification Types


a)    Normal identification

1)   Mandatory properties
2)   Assistive properties

b)    Smart identification

1)    base filter properties
2)    optional filter properties

c)    Ordinal identifier
 
1)    location
2)    index
3)    creation time(only for Browser)

QTP learns information in the following in case of normal identification:
 

First of all the qtp learns all the mandatory properties at a time and thinks whether these properties sufficient to identify the object uniquely. if it feels sufficient then it stops learning otherwise,
It learns first assistive property and once again stops and thinks, like this qtp learns one by one. At the end of assistive properties list also if it feels not satisfied and it finally goes to Ordinal Identifier.


QTP learns information in the following in case of Smart Identification:

Smart identification is an optional feature, if we feel normal identification is not sufficient for any object, and then we configure Smart Identification for that object, in order to avoid Ordinal Identifier.

After normal identification if qtp feels not satisfied then it goes to smart identification. in smart identification 2 types of properties available, first qtp learns all base filter properties at a time and thinks whether these properties are sufficient for identifying the object uniquely. If it feels sufficient, then it stops learning otherwise it goes Optional Filter Properties and learns one by one. Still it feels not satisfied finally it goes to Ordinal Identifier.

Ordinal identifiers:

There are 3 types of ordinal identifiers available

1) Location: is based on object location in the AUT ,location starts from zero.
 
2) index: it is based on sequence of the programs, index starts from zero
 
3) Creation time: it is based on loading time of the web objects. qtp generates 0,1,2 like numbers.

Tool Settings Globalization:

As QTP is a I-tier(Stand-alone) application,making Tool settings globally is not possible.


For making tool settings global, QTP is providing a special feature called "Generate Script".

STEPS:

1) Settings available in 3 areas.
    

    a) File->Settings
    b) Tools->Options
    c) Tools->Object Identification

2) Perform required settings and generate Scripts

3) Share Script files to team members and ask them to execute those scripts.

NOTE: After executing these scripts all team members can get same settings.
When a QTP Test is run, QTP checks for Logical name and the control checks in the object repository for Test Object and corresponding Properties of the test object and based on these details QTP checks for the run time object in the AUT and performs the actions associated with the run time object.

Note: The logical name in the script and the name of the test object in the Object Repository should be the same. These are steps performed to identify an Object.


Step 1: During a run session, QTP encounters a line of Code, picks the Logical name from the Script.

Step 2: The control goes to the Object Repository, Quick Test searched for a test object with the logical name.

Step 3: Once the Test Object is found, Quick Test picks the properties of the object listed in the Test Object Details section of the Object Repository (OR).

Step 4: The control goes to the AUT, makes use of these properties to uniquely identify a Run Time Object.

Step 5: Once the Object Identification is completed, Quick Test executes the specified method on the Object.

Repeats all the steps till all the lines of code is executed.

Note: It is always good to have User Friendly Logical names for Test Object in the Local Repository. For Example WinButton("Button").Click to open a New Page can be written as WinButton("New").Click which is user friendly.

To change the Name of the Object if you change in the Script it would not make the changes in the Object Repository but if you select the Test Object in the Object Repository and change the Object name in the properties window then it would be replicated in the Script.

No comments:

Post a Comment