Skip to main content

QTP - Object Identification Types / Ways

In QTP, we can use lot of ways to identify an object. Most of the QTP 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.
1. 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.
2.Description Object:
If you have lot of properties to instruct QTP 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 QTP 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"
Refer XPATH.

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"
Refer CSS Path.

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 QTP, 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 QTP test developers. Just we are creating an image of our object and instructing QTP 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 QTP machines. 
This feature is used rarely by QTP 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 QTP to identify the objects as manual testers are doing in real time by seeing visually using eyes. i.e. We can instruct QTP 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.
We will see a separate topic for this add-in creation later here.

Comments

Popular posts from this blog

Some good Resources / Blogs / Sites for Selenium Users

Here I have listed out some good blogs and sites by extensive selenium automation users. Hope these will help you a lot. http://automationtricks.blogspot.com  - by NirajKumar http://www.theautomatedtester.co.uk/ http://testerinyou.blogspot.com   - by Naga/Mathu http://seleniumready.blogspot.com  - by Farheen Khan http://seleniumdeal.blogspot.com/  - Amit Vibhuti http://seleniumexamples.com/blog Sauce Labs and BrowserMob are companies doing cloud and extensive selenium automation services, products, etc http://saucelabs.com/blog http://blog.browsermob.com http://testingbot.com/ Cedric Beust -  creator of the TestNG Java testing framework. http://beust.com/weblog/ http://blog.reallysimplethoughts.com/  - by Samit Badle, Created many Selenium IDE Plug-Ins Available Colud Testing: 1. SauceLabs 2. Soasta 3. BrowserMob 4. CloudTesting.com  etc. Selenium Testing Products: 1. Twist by ThoughtWorks 2.  TestMaker by  PushToTest 3. Element34 company providi

UFT - Take full page screenshot by scrolling the page

'######################################################################################## 'This is navigate through the full page and taking individual screenshot of visible area '######################################################################################## Function TakeScreenshot Dim intScrolls, intScroll, strScrollPos Set pgApp = Browser ( " " ) .Page ( " " ) intScrolls = Round ( pgApp . RunScript ( " document.documentElement.scrollHeight / (screen.height) " ) , 2 ) If intScrolls < 1 Then intScrolls = - 1 pgApp . RunScript " window.scrollTo(0, 0); " Wait 1 Browser ( " " ) .CaptureBitmap " C:\screenshot0.png " , True For intScroll = 0 To intScrolls If Environment . Value ( " Browser " ) = " CHROME " Then strScrollPos = " scrollY " Else strScrollPos = " document.documentElement.scrollTop " End If If p

Change IE Browser ZOOM settings

Lot of UI automation testers could have faced this problem as we could change the zoom settings while operating manually for our convenience and forgot to reset to 100%. But our QTP and some other related tools would operate the browser perfectly if browser zoom is 100%. So wee need to change the zoom before start to run the scripts. Its better to have a code snippet in our framework to change this zoom setting right? Here we go... 1. We can simply change the Registry values before Invoking IE Function  ChangeRegistry   Dim  objShell   Set  objShell =  CreateObject ( "WScript.Shell" )  objShell.RegWrite  "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Zoom\ZoomFactor" ,  "100000" ,  "REG_DWORD"   Set  objShell =  Nothing End   Function This option is very useful. But in real time, lot of customers could have restricted write access to windows registry. So we can try other options. 2. Use IE COM object and Change