Tricentis Tosca 16.0 Released on Feb-2023 ----- UFT has been upgraded from UFT 15.0.1 to UFT One 15.0.2, Beginning at November 2020.

Thursday, 1 October 2015

QTP - Object Identification Types / Ways

In UFT, we can use lot of ways to identify an object. Most of the UFT Test Developers are always using streamlined and static approaches and if object is not identifiable using those approaches, just leaving then as not identifiable.

We can try using below ways of handling objects for our purpose before saying NO !!!

1. Store the objects in OR

If you are comfortable on using OR and suitable for your project with your designed framework, you can go ahead with OR.
a. Add the object in OR, then see what are the properties will make QTP to identify this object uniquely. 
b. Remove unwanted properties
c. Add unique and required properties
d. Assign regular expressions for the required properties which have dynamic values in full or part. Make use of Reg Exp Evaluator to set the RegExp correctly.
e. Assign a human understandable, easily classifiable logical name for the object based on type of object, application module or screen, etc.

2. Use Descriptive Programming
Here you can use 2 types of DP.

A. Inline or String DP:
Mention your properties in the line where we are mentioning our actions to be performed using “name:=value” pairs. 
Here the important point is, this type of object identification is regular expression support enabled by default. So you have to use literal character(\) if any regexp chars available as part of your name:=value pairs.

B.Description Object:
If you have lot of properties to instruct UFT to identify an object, inline DP will create lengthy statement and confusion. At this point, you can go with Description Object.
Create an instance of Description object and assign the values for all the required properties. Also you need to assign RegularExpression property true/false to enable the regexp support for the assigned properties.

3. Xpath
From QTP 11, you are ready to use xpath for web objects. Really its an easy way to inform the web objects path to UFT as like our normal DP.
Ex. To get the google search box

Browser("title:=.*google.*").Page("title:=.*google.*").WebEdit("xpath:=//INPUT[@name='q']").Set "testing"

4. CSS Path
This also supported from QTP 11 like xpath.
Ex.To get the google search box

Browser("title:=.*google.*").Page("title:=.*google.*").WebEdit("css:=INPUT[name='q']").Set "testing"


5. DOM Path
This one you can use from previous versions of QTP. This is a method where we are directly fetching our objects from web page document using DOM.
In UFT, they have provided a function called RunScript and RunScriptFromFile for PAGE objects to execute the scripts on the page to get the objects.
You can make use of IE developer tools (press F12 to open in IE) to check and develop your DOM scripts.

Ex.To get the google search box

Browser("title:=.*google.*").Page("title:=.*google.*").RunScript("document.getElementsByName('q')(0)").value = "testing"
Refer QTP RunScript.

6. Virtual Objects
This is a known way to all UFT test developers. Just we are creating an image of our object and instructing UFT to identify runtime object based on the image.
Here you need to take extra care with respect to different environments, themes and also need to place the virtual objects folder to all UFT machines. 
This feature is used rarely by UFT developers worldwide but based on this type of image recognition, we have lot of automation tools in current world.

7. Virtual Relation Identifier
From QTP 11, we have an option to instruct UFT to identify the objects as manual testers are doing in real time by seeing visually using eyes. i.e. We can instruct UFT like,
a. Click the button which is available next to an identifiable button/element in horizonally.
b. Click the button which is available next to an identifiable button/element in vertically.
c. Click the button which is available before to an identifiable button/element in horizonally.
d. Click the button which is available before to an identifiable button/element in vertically.

You can instruct these properties in Object Repository itself  for Visual Relation property. Also, we can instruct this type of visual relation in programmatic way using Descriptive Programming without using Object Repository.

8. Create Custom Add-Ins
Create custom Add-Ins? What? Can we create add-ins ourself?
Yeah !!! QTP 11 provides an tool/utility called QTP Extensibility Accelerator to create custom add-ins for the custom objects support in your AUT. Currently, QTP 11 provides a add-in creation template for Web Objects only. We can create our custom add-in with in 10 mins. But for other environments, you need to create using some IDE, need some basic VB or other coding knowledge. But we can create custom add-ins for all type of objects using this tool.


No comments:

Post a Comment

Note: only a member of this blog may post a comment.