Sunday, 17 January 2010

Debugging Flex/QTP Issues

Once you have setup a working QTP build, debugging problems can be really tricky. This is mainly because the errors that are reported (if any) aren’t particularly helpful and the documentation is pretty slim. It can also be pretty hard to know how to tackle QTP performance issues. This post will explain some of the techniques I’ve found useful in debugging and solving these issues.

When the Flex/QTP integration encounters an error it traces the problem rather than logging it. This means that to debug problems you will need to connect your QTP enabled application to a debugger in order to see the trace statements. This can make everything run very slowly, so I suggest enabling the logging of trace to a log file which you can examine when you encounter a problem. This can only be done on a debug player, full details can be found here. The second place you can look is QTP’s logs, although I have generally not found them to be very helpful. An explanation of how to enable these logs can be found here.

The most common problem I've encountered while recording or replaying QTP scripts is the object you are trying to identify simply shows up as a “WinObject” or “ActiveX Object”. This happens because QTP cannot detect the hierarchy of object within Flash Player so it simply identifies it an the ActiveX object, i.e. the ActiveX Flash Player. When you see this happen there should be trace of the error message that has occurred for you to check. Most frequently the error message will be “2 matches for criteria {...}”, this generally means that QTP found 2 or more objects that appear to be the same. By default QTP will only use the type of the object, the automationName and the object's location to uniquely identify it, so if multiple objects exist that are the same type and have the same or no automation name then this error will occur. Remember that QTP does not necessarily see the same hierarchy of objects that actually exist in your view. Components that are under different parents may appear to be under the same parent to QTP if the common parent has its showInAutomationHierarchy set to false. This problem can easily be solved by picking unique automation names and including extra containers in the automation hierarchy to ensure uniqueness.

When built with automation support, mouse clicks only propagate through one level of the view hierarchy. This means that if you have a container on top of another component, say a button, you will not be able to press the button, and hence record clicks on it.  Details of this "bug" can be found here. One way around this is to rearrange your view so the component you wish to interact with is on top of the container, alternatively you can set mouseEnabled to false on the container so the event propagates through.

The performance of recording and replaying QTP scripts should generally be good on a small application but it can become a problem on larger applications. QTP descends the view hierarchy looking for the components to interact with, this can become slow in certain situations. It seems that the search works much better if your tree of components, that QTP sees, is deeper rather than flat. This can easily be achieved by setting showInAutomationHierarchy to true on key containers. This partitions the search space and makes it faster to search, and hence replay scripts. The downside of this is that the scripts recorded will have longer chains of components which couples the scripts even further to the layout of your application. This coupling is a problem when you change the layout of view components in your application because your QTP scripts will need updating to reflect the new layout. Flex 4 claims to improve this performance issue relating to automation.


  1. Hi,

    Your posts are really helpful.

    Recently while trying to automate flex application ,i found that qtp was unable to record any actions performed on ADvanced datagrid.QTP version is 9.5 and sdk use dto compile application is 3.2.with Flex datagrids everything was fine.Do we need to do extra configuration

  2. This comment has been removed by the author.

  3. Hi there,

    thanks for an awesome set of postings on getting QTP and automation api working. I wish I had found this before having to encounter and debug the same issues.

    One issue you may not have enountered is with sdk 4.1 and the RandomWalk example. Playback is failing (I logged this here -

    Repeat/Summary of the obstacles encountered are:
    * must have ‘-includes=RandomWalkDelegate’
    * you have to make certain you run the Adobe Flex 4 Plugin for HP QuickTest Pro\Install_QTP_Plugin.bat to install the each time you change the TEAFlexCustom.xml or TEAFlex.xml file.
    * You have to restart QTP
    * You have to use the -include-libraries in additional compiler arguments
    -include-libraries "C:\Program Files\Adobe\Adobe Flash Builder 4\sdks\3.5.0\frameworks\libs\automation.swc" "C:\Program Files\Adobe\Adobe Flash Builder 4\sdks\3.5.0\frameworks\libs\automation_agent.swc" "C:\Program Files\Adobe\Adobe Flash Builder 4\sdks\3.5.0\frameworks\libs\qtp.swc" "C:\Program Files\Adobe\Adobe Flash Builder 4\sdks\3.5.0\frameworks\libs\automation_dmv.swc" "C:\Program Files\Adobe\Adobe Flash Builder 4\sdks\3.5.0\frameworks\libs\automation_flashflexkit.swc"

    The version of RandomWalk had to be patched as per

    add Wait(5) commands in the QTP generated script to get it to work