I used QTP 9.0 to automate testing of an application. However, code that passed a test case on the first run, often failed on the second run.

For instance, the code:

'start a new search
VbWindow("frmMain").VbWindow("frmSpecialDesignatio nSelection").VbButton("Search").Click
wait 1
VbWindow("frmMain").VbWindow("frmSpecialDesignatio nSelection").VbButton("Search").Click
'wait for the search results to appear, select a record, and press the Designate button
wait 2
VbWindow("frmMain").VbWindow("frmSpecialDesignatio nSelection").WinObject("AfxOleControl42").Click 377,164
wait 3
VbWindow("frmMain").Window("Special Designation").RunAnalog "Track16"
VbWindow("frmMain").Window("Special Designation").RunAnalog "Track16"

contains the following techniques that stabilize the QTP code a bit, but do not cure the problem:
- Adding a “WAIT” statement after the “Search” button in the above code is pressed
- Preceding an Analog recording with a “WAIT” statement
- Pressing “Search” twice (instead of once)
- Repeating the Analog recording

The most common causes of instability I encountered were:
- QTP can’t find an object (often an icon at the first step of the test script)
- The application I tested has 3rd-party controls not recognized as Microsoft buttons, check boxes, etc. Thus I had to use Analog recordings, which sometimes failed to run. This problem could be due to even slight changes in screen resolution or other pixel changes, but it seems to occur even without this type of change.
- After pressing the “Search” button, the search-results window is dead, so I can’t double-click a search result. This window seems to be a 3rd-party control, since QTP can’t recognize the individual search result (a strip that runs from left to right) as a separate object.

I have the following questions:

1) Is there a way to make my QTP code pass test cases more consistently?

2) Would upgrading to QTP 9.1 or 9.2 solve this consistency problem?

3) In some cases, I can’t verify that individual fields are disabled. The controls are disabled on the screen but their “Enabled” property is True because instead of disabling each control, the developer set the Frame property to False. Is there any way to program QTP to verify that the fields are disabled?

Thank you.

- Neil