| || |
how could I implement by best way the following:
I have a progress, which takes a while.
then I wrote wait(10) for example.
But if it takes longer, the next step will be executed.
How can I implement a function, which will wait until the progress is finished?
Thanks a lot,
Re: wait for
You'll have to find some object to watch then loop until it no longer exists or whatever the scenario happens to be for the app.
Re: wait for
First, try to avoid simply using wait statements. When you use wait(10) and your application is ready in 3 seconds, you will still wait the full 10, wasting 7 seconds. And when you need 15 seconds, wait(10) won't solve your problem, as you've pointed out.
Instead, consider using waitproperty() methods that you can apply to just about any object.
So, for example, maybe you just clicked a Submit button, and now your application is communicating with a database, then with your file server to load a new page. And once this new page opens, you want to click a Confirm button (for example) but the whole process usually takes anywhere from 5 seconds to 20 seconds.
In this example, you would put a waitproperty("enabled",30) on the Confirm button. This will tell QTP to wait up to 30 seconds for the Confirm button to be enabled. The neat thing about waitproperty() is that if the property is found before the time you specify, QTP will move on to the next line without waiting the rest of the time - so it only waits as long as it has to.
As a rule, put the waitproperty() method on the very first object you want to interact with after the wait. Since you are interacting with that object first, there is no reason to wait for some other object - wait for the one you need first.
Also, as a side note, consider the .exit() method, which does much the same thing, but waits for an object to exist (note that just because it exists doesn't mean you can interact with it - for example, some applications might instantiate the Continue button first but make it disabled until the rest of the data loads).
"The last 10% of any software project will take 90% of the budgeted time. The first 90% will take the other 90%"