tags:

views:

204

answers:

5

We have an application where some files are being loaded and the application stops responding for some time during the loading of the file. during test automation, we are having the scenario where the file loading is automated, but qtp has to wait until the application starts responding again. How to code this? Any property is there like "Wait"?

+2  A: 

Insert a synchronization point on one the application objects, such as a button, being enabled. The synchronization point allows you to specify the timeout period.

Tom E
+2  A: 

Any property is there like "Wait"?

If so, then it is application-specific, so to answer that one would need to take a technical look at your application's GUI design.

Generally speaking, consider how a human user would figure that the application is "responding" again. Usually, there is some visual hint, like a button appearing, or a some control being not greyed out anymore. Synchronize on that state using a synchronization point.

If all fails (i.e. if you cannot identify a control that appears, disappeares, or changes its properties when application's processing is over), stick to a bitmap checkpoint which would look for the same visual clue a human would interpret.

Often, the synch point or visual hint comes a little too early, before the application is ready to accept input again. Then, if your application flushes the keyboard buffer before the next user input is expected (an example of widely common bad design...), you will have a hard time synchronizing correctly. Keystrokes and mouse clicks will be lost. In this case, you should a) workaround the problem by inserting a delay (wait function call) before the next input, b) establish that the application never flushes its input queue, c) enforce that the visual clue is done only after the app REALLY is ready to accept input. Of course, b) and c) require work on the developer's side and might be organizationally difficult to implement.

If the problem occurs in different, or even all, contexts, communicate it to test management and let them get the developers to implement a custom "Ready" signal just for your test robot. Then, you could query that signal from QTP. It could be a semaphore, a Windows string property (Set/GetPropEx API call), a file existance (baaad idea..), or some other undangerous yet unsynchroneous way of communicating the "Ready" state from the app to the test robot.

All this sounds crazy, but I've done all of the above, with usually good results.

TheBlastOne
+2  A: 

You can use a generic Wait(seconds) if you want a quick and dirty fix. For example, if you know that your application will be ready to use in less than a minute. If it varies based on the amount of data however, you could try using the 'Exist' proprty of a control on your application that is loaded once all of the data has been processed. ie.

while not loaded
wait(1)
loaded = Window.Control.Exist
Wend
Todd Bumbarger
Note Exists has some nice bugs in 10.00, returning always true for specific controls. Use GetProperty ("micclass") = "<yourclassnamehere>" in such cases.
TheBlastOne
A: 

In my opinion, the simplest and reliable solution would be to invoke WinAPI's IsHungAppWindow from user32.dll directly. QTP allows you to declare external functions easily.

Andrey
Hehe...so what should he wait for -- for the IsHungAppWindow function returning true for his app's window? Or false? This just lets you know if Windows considers this a "not responding" application. All apps that do not poll their message queue are considered "not responding". This does not mean that an app that is not "not responding" is ready to accept and process input from the test robot perspective...That fact, and the timeouts involved, make IsHungAppWindow no good recommendation.
TheBlastOne
you seem to over-complicate things. Topic starter described situation in which an app get unresponsive (read - doesn't handle messages) while performing some operations. IsHungAppWindow would identify exactly this situation. This solution is quite easy to implement in automatic testing tools, simply call a dll function.
Andrey
A: 

We can use While Loop to wait for the Application page screen to be visible, once loaded the script should proceed with the next screen

Kartmcad