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"?
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.
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.
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
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.
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