What do you do when QuickTest Professional (QTP) doesn’t automatically recognize an object in your application? In my experience, these are the first six things to try/check.
1.Check the loaded add-ins:
It’s pretty basic, but be sure you have the correct add-ins selected. If QTP is only recognizing your objects as standard WinObject this may be a sign that you need to use an add-in. Sometimes QTP’s ‘Display Add-in’ Manager on start-up option, under Tools\Options\General may not be selected. This setting may cause you to start QTP on a machine and mistakenly assume that all of the correct add-ins have been chosen. Double-check by opening your script and selecting File\Settings under Properties ‘Associated add-ins:’ verifying that all the needed add-ins are listed. Also make sure QTP is started before the application under test. QTP will sometimes not recognize a web application if the browser was opened before QTP.
HP’s Knowledge base:
Research the issue. If your add-ins are fine, the next step is to search the HP’s Knowledge base. Again, this may seem obvious, but a surprising number of people fail to do this. There’s nothing worse than spending hours on a script only to discover later that there is a patch (for example see patch that resolves some QTP 11 object issues) available or a posted solution that will solve the problem. I'm sometimes hailed as an automation genius by fixing something that an engineer may have been struggling with for days, based on information I found in the KB. Often, even after I tell the engineer how I solved the issue, they still don’t check the KB the next time they have a problem. Do me a favor — don't be that guy (or gal)! Check the KB. (If nothing is found in the KB, another great resource to check is SQAForums.
3. Using .Object:
Look at all the available object’s operations (both the “identification properties” and “native properties” methods). You'll be surprised what you'll find lurking around in an object’s properties that may help to automate it. Using .Object try as many operations as possible–even ones that may not seem remotely relevant to the action you want to perform. For example: I was having a problem recognizing text on an application’s custom .NET grid. After spying on the object and trying several different methods that sounded promising, I ended up trying an odd one, called GetViewStyleInfo, and surprisingly it worked!
Check out my post Secret on How to Enter Text in a WebElement for another example of using the .Object method.
4. Try GetVisibleText:
Sometimes QTP does not recognize text in an object using the GetROProperty(“text”) method. As a last resort, try using the GetVisibleText, GetTextLocation and Type methods. These methods really helped me automate some old proprietary controls. Using a combination of QTP’s TYPE method and GetTextLocation, I created a very reliable rich edit box object function. For example:
If you are using UFT 12.1 good news -UFT's GUI Insight recording now support using the GetVisibleText method to retrieve text from a specified area
5. Developers are your friend:
The application's developers can help you. Ask your developers to expose a method or add a property that will make automation easier. But before you ask — make sure you've exhausted all the above suggestions. Developers can be a tough bunch, and you really don’t want to annoy them with things you could have resolved on your own. I work with some awesome programmers, and as long as I'm able to clearly explain to them what I need and why they never hesitate to help.
6. Make sure there is not a patch that will help.
Sometimes there are known issues with object recognition that only a QTP patch will resolve. Also new patches sometime include support for newer version of AUT like .NET or Browsers.
For an updated list of all patches available for QTP 11 check out the Patches section in my article:QTP 11 Support Matrix with Patch Updates
Also there may be issue with QTP/UFT and the .NET version you are using like:
- QTP UFT – Object Recognition Issues with .NET
- QTP .NET 4.0 Object Recognition Issues
These are my top 6 suggestions – what are yours?
- Tip 6.1 – From Mike G Marshall “Another thing to check is “Record and Run” setting under Automation menu. If you try and identify an object in an application that doesn’t match the rules here, it will show as a standard Windows object.”
- Tip 6.2 – From Michael te Wierik – “I don’t know how many times I have slaved away to find a solution to an object identification issue, and then remembered to use “Low level recording” from the Automation menu when recording. Its a massive timesaver.”
(UPDATE: 11-03-2014– For an updated list of what to try for UFT and QTP object recognition issues listen to my podcast episode —->10 TEN THINGS TO TRY WHEN QTP/UFT DOES NOT RECOGNIZE AN OBJECT<—)