QTP is a mysterious tool. Its been around 3 years that I have been investigating this mystery but still I think there’s a long way to go in solving it.So, you are stuck ! irritated with QTP ? Here are a few things (in order) that you can try if you are not able to identify an object :-
1. Order of opening Application – Make sure that QTP was opened before the application under test. Otherwise all objects will be identified as WinObjects.
2. Check whether required Add-ins are selected or not – It happens a lot of times where we wonder why the objects are not identified, but its as simple as selecting the correct add-ins.
3. See if there is a patch that can help you – There are a lot of patches available for QTP. For eg: you’ll have to use the QTP_00699 for a 64 bit machine, QTPNET_00120 for WPF (.NET). Refer http://support.openview.hp.com/selfsolve/patches for more (you’ll need an HP ID for this)
5. Native Methods – You can try out the Native methods of any object by writing .Object after the object and then calling the required method.
For eg : Browser(“name:=Google”).Page(“title:=Google”).Object.getElementByID(“XXXX”).Value=”QTP”
Same as the above, you can also use the native methods of .NET/Java/other types of applications. If you are automating a .NET Application, you can try using the .NET Object spy which exposes the native methods of .NET which can be used to play around with the .NET objects.You can also take the developer’s help if your application consists of Custom classes.
6. UFT Insight – If you have the liberty of using UFT, you can go ahead with using Insight which uses Image based identification to perform operations. You can click or type on an Insight object. Coming soon – Insight tutorial.
7. Consider using SendKeys/Device Replay – If you don’t want to bang your head with the all the solutions possible. Just go ahead and use sendkeys/device replay to solve this (if you application has a shortcut for invoking the operation). For more details about sendkeys, you can refer – http://msdn.microsoft.com/en-us/library/8c6yea83(v=vs.84).aspx. For device replay, stay tuned for my next post. Please note that this may not be a very reliable way of automation as we need to make sure about the focus of the application for these methods to work. So please use Activate/Highlight before sending the keystrokes.
8. Use Methods GetvisibleText,GetTextLocation,ClickonText – You can try using any of these methods if you are not able to perform an operation with conventional methods :-
a) GetVisibleText – object.GetVisibleText will use OCR and tell you what is written on a specified area(use this if you are not able to use GetROProperty(“text”))
b) GetTextLocation – This will return the Left,Top,Bottom and Right coordinates of the text that you will give.
Example : strFound =Window(“”).Dialog(“”).GetTextLocation (“OK” ,left,top,bottom,right)
c) ClickonText – You can use this to click on any given text on an application, if you are not able to identify the specific object but you know the text written on the object.
Syntax – ClickOnText(TextToFind, Left, Top, Right, Bottom, MatchWholeWordOnly,ButtonToClick,DoubleClick)
Example – Window(“”).Dialog(“”).Clickontext “OK”,x1,y1,x2,y2,true,micRightbtn,false
Happy Automating !
Categories: Common Issues