Facebook

Course Name Start Date Time Duration Registration Link
No Training Programs Scheduled ClickHere to Contact
Please mail To sudhakar@qtpsudhakar.com to Register for any training

Thursday, February 12, 2009

Object Identification in QTP

This concept is tells about how QTP is identifying objects while running and recording session.


Object Identification in running session

If you record in Normal or Low level recording, object information will store in object repository. In script you can see class, object name, operations, and values.
After starting running first QTP will see the class, object name in script and it searches for the same object name in object repository. If that name exists in object repository then QTP will identify the object in application using recorded properties in object repository.


Object repository

It is the place where the Recorded object information will store. In this you can see all objects properties and you can edit, modify and delete properties of the objects.
The objects and properties stored in object repository are called as Test Objects and TOproperties.


Object Repository Dialog box
 

Adding objects

In the Object Repository window, choose Object--> Add Objects to Local. Click the object you want to add to your object repository.

If the object is associated to any other object then you will this dialog box.

Selected object only: - Adds to the object repository the previously selected object's properties and values, without its descendant objects.

Default object types: - Adds to the object repository the previously selected object's properties and values, with the properties and values of its descendant objects according to the object types specified by the default filter. You can see which objects are in the default filter by clicking the Select button and then clicking the Default button.

All object types: - Adds to the object repository the previously selected object's properties and values, together with the properties and values of all of its descendant objects.

Selected object types: - Adds to the object repository the previously selected object's properties and values, as well as the properties and values of its descendant objects according to the object types and classes you specify in the object filter. You specify the objects and classes in the filter by clicking the Select button and selecting the required items in the Select Object Types dialog box.

Click on the select button to select the objects. After clicking on select this dialog box will open.

Select the filter type and add the objects to the repository.

Modifying properties of the objects

Select the object which you want to modify properties and go to description properties there select the property value. Automatically the property value will be edit; you can change that value to any value.

Changing name of the object

Select object in repository, right click-->Rename and change the name.

Deleting objects from repository

Select object in repository, right click-->Delete.

Highlighting Object

Select object in repository View --> Highlight in Application. This will highlight object in application.

Locate in Repository

Go to View --> Locate in Repository and select object in application if object is there in repository then that object will be selected.

Object Spy


Navigation: - Tools-->object spy

Using the Object Spy, you can view the run-time or test object properties and methods of any object in an open application. You use the Object Spy pointer to point to an object. The Object Spy dialog box displays the selected object's hierarchy tree. It displays the run-time or test object properties and values of the selected object in the Properties tab. It displays the run-time or test object methods associated with the selected object in the Methods tab.

       

To use object spy Click on the hand button showing in up side and show the object to that hand button Quicktest will automatically displays properties of that object.

Tip: - Hold Left ctrl key for navigating on the application after clicking on the hand button.

By default object spy will show the runtime object properties for web application but not for window applications.

Object Identification Dialog box

Navigation: - Tools--> Object Identification

It is mainly deals with how QTP is recording objects and properties to object repository.

Using Object Identification dialog box we can
  • Configure the properties for each class
  • Selecting the Ordinal Identifier
  • Configuring smart identification
  • Creating user defined classes
In object Identification Dialog box you can find list of classes, for every class you can find pre-configured Mandatory and assistive properties.

Mandatory properties are properties that QuickTest always learns for a particular test object class.

Assistive properties are properties that QuickTest learns only if the mandatory properties that QuickTest learns for a particular object in your application are not sufficient to create a unique description. If several assistive properties are defined for an object class, then QuickTest learns one assistive property at a time and stops as soon as it creates a unique description for the object. If QuickTest does learn assistive properties, those properties are added to the test object description.

If the combination of all defined mandatory and assistive properties is not sufficient to create a unique test object description, QuickTest also records the value for the selected ordinal identifier.

Ordinal Identifier

In general, there are two types of ordinal identifiers:

Index—indicates the order in which the object appears in the application code relative to other objects with an otherwise identical description.

Location—indicates the order in which the object appears within the parent window, frame, or dialog box relative to other objects with an otherwise identical description. Values are assigned from top to bottom, and then left to right.

The Web Browser object has a third ordinal identifier type:

CreationTime—indicates the order in which the browser was opened relative to other open browsers with an otherwise identical description. Each test object class has a default ordinal identifier selected.



Configuring Mandatory properties

In object identification dialog box select the object class from test object classes list and go to Mandatory properties for that class.

Click on Add/Remove button and select or deselect the properties you want to configure.

Configuring Assistive Properties

In object identification dialog box select the object class from test object classes list and go to Assistive properties for that class.

Click on Add/Remove button and select or deselect the properties you want to configure.

Configuring Ordinal Identifiers

To modify the selected ordinal identifier, select the desired type from the Ordinal identifier box.

Smart Identification

When QuickTest uses the recorded description to identify an object, it searches for an object that matches every one 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 recorded object description, or if it finds more than one object that fits the description, then QuickTest ignores the recorded description, and uses the Smart Identification mechanism to try to identify the object.

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

Optional filter properties—Other properties that can help identify objects of a particular class as they are unlikely to change on a regular

Understanding the Smart Identification Process

1. QuickTest “forgets” the recorded 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 property list.

2. From that list of objects, QuickTest filters out any object that does not match the first property listed in the Optional Filter Properties list. The remaining objects become the new object candidate list.

3. 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.

4. 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 recorded description plus the ordinal identifier to identify the object.

If the combined recorded description and ordinal identifier are not sufficient to identify the object, then QuickTest stops the test run and displays a Run Error message.

If QuickTest successfully uses Smart Identification to find an object after no object matches the recorded description, the test results receive a warning status and include the following information:



Normal Identification fails to finds the object so that the warning message is showing.


If Quicktest uses Smart identification to find an object, a cap symbol will be appear in results where ever it is using.
And some description will show in results saying that how Quicktest identifies the object using smart identification.



In this example, Base filter properties prepares an objects list. (17 objects)

And optional filter properties filtered those object list using available properties.

If one property fails it’s using another property to find an object. If any property is finding one object QTP is ignoring other properties.

Where as in Normal Identification process all properties in object description should satisfied. If one property fails all object identification process will fail.

Configuring Smart Identification

In object identification window select a class in test object class list--> select option “Enable Smart Identification”--> Click on Configure

Then “Smart Identification Properties – class name” will be appearing…



Click Add/Remove to add or remove properties in Base and optional filter properties.

Note: - By default smart identification is configured and activated for web environment.

Mapping user defined test object classes 

If your application has a button that cannot be identified, this button is recorded as a generic WinObject. You can teach QuickTest to identify your object as if it belonged to a standard Windows button class. Then, when you click the button while recording a test, QuickTest records the operation in the same way as a click on a standard Windows button. When you map an unidentified or custom object to a standard object, your object is added to the list of Standard Windows test object classes as a user-defined test object. You can configure the object identification settings for a user defined object class just as you would any other object class.

Note that an object that cannot be identified should be mapped only to a standard Windows class with comparable behavior.

For example, do not map an object that behaves like a button to the edit class.

Note: You can define user-defined classes only when Standard Windows is selected in the Environment box.

The Object Mapping dialog box enables you to map an object of an unidentified or custom class to a Standard Windows class.

To map an unidentified or custom class to a standard Windows class:

  1. Choose Tools > Object Identification. The Object Identification dialog box opens.
  2. Select Standard Windows in the Environment box.
  3. The User-Defined button becomes enabled. Click on User-Defined button. The Object Mapping dialog box opens.

  1. Click the pointing hand and then click the object whose class you want to add as a user-defined class. The name of the user-defined object is displayed in the Class Name box.
  2. In the Map to box, select the standard object class to which you want to map your user-defined object class and click Add. The class name and mapping is added to the object mapping list.
  3. If you want to map additional objects to standard classes, repeat steps 4-5 for each object.
  4. Click OK. The Object Mapping dialog box closes and your object is added to the list of Standard Windows test object classes as a user-defined test object.
  5. Note that your object has an icon with a red U in the corner, identifying it as a user-defined class.
  6. Configure the object identification settings for your user defined object class just as you would any other object class.
From here after that mapped user defined class objects records like standard class objects.


Object Identification - Conclusion
When you start recording on the application, QuickTest "looks" at the object on which you are recording and stores it as a test object, determining in which test object class it fits. QuickTest might classify the test object as a standard Windows dialog box (Dialog), a Web button (WebButton), or a Visual Basic scroll bar object (VbScrollBar), for example.
Then, for each test object class, QuickTest has a list of mandatory properties that it always learns. When you record on an object, QuickTest always learns these default property values, and then "looks" at the rest of the objects on the page, dialog box, or other parent object to check whether this description is enough to uniquely identify the object. If it is not, QuickTest adds assistive properties, one by one, to the description, until it has compiled a unique description. If no assistive properties are available, or if those available are not sufficient to create a unique description, QuickTest adds a special ordinal identifier, such as the object's location on the page or in the source code, to create a unique description.
Similarly, during a run session, QuickTest searches for a run-time object that exactly matches the description of the test object it learned while recording. It expects to find a perfect match for both the mandatory and any assistive properties it used to create a unique description while recording. As long as the object in the application does not change significantly, the description learned during recording is almost always sufficient for QuickTest to uniquely identify the object.
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.
If QuickTest is unable to find any object using smart identification then QuickTest uses Combination of Learned description and ordinal identifiers to find the object uniquely.

5 comments :

  1. Need help : QTP 10.0 not recognizing java applets

    Hi Sudhakar,

    I am setting up QTP env for automation run and stuck at a point. I am facing this issue of java applets being not recognized and treated like winobjects:sunawtcanvas.
    This is the behavior while running as well as recording.I have tried asking many people here and also googled a lot but so far no luck.
    Will you be able to have a look into it ?
    I am using :

    QTP 10.0
    Java Plug-in 1.6.0_21

    PFA results.xml for one of the test cases.


    When i try to manually add java applet to object repository it is recognized as win object.Here is a screenshot of objectspy



    Any help will be much appreciated.

    Regards,
    Raj

    raj.ubi2001@gmail.com

    ReplyDelete
    Replies
    1. Ensure that you lanuch QTP first and then the java applet you are trying to automate. This helps in most cases. Let me know...
      Vaibhav

      Delete
  2. This comment has been removed by the author.

    ReplyDelete
  3. You have very detailed and understandable information in each topic of qtp... superbbb

    ReplyDelete