Making QTP wait for application to load
Question ID: 104832
0
0

How can I make my script wait for an unpredictable amount of time before testing the application. I have a situation where I launch the application I’m testing, but there is a long delay while the application loads and does a huge data ‘pre-fetch’. I don’t want to use a synch point because the delay is not predictable, but it should eventually come up. It could even take up to an hour in some instances, but I want the script to wait until the application is ready. Is there a way to do this that you know of?

Marked as spam
Posted by (Questions: 227, Answers: 22)
Asked on February 1, 2013 2:39 am
122 views
Answers (1)
2
Private answer

Probably the best approach with something like this is to utilize the .Exist method in QTP. Most objects (if not all) test objects are able to use an .Exist method and this simply returns True or False depending on if the object is found or not. Combine this with a simple If/Then statement and you can put it in a loop that waits until the object is displayed (exists) in the GUI. Here's an example that shows this. You could simplify the code if you wanted to, but I'm going to break things out a little more than I would normally just for illustration.

Notice that I'm also using a small delay in the Exist statement to prevent tying up the processor constantly. In this example I check for 2 seconds and then wait for 5 seconds:

flag = False
Do Until flag = True
flag = Window(''App Window'').WinEdit(''username'').Exist(2)
Wait 5
Loop
.................
.................rest of script resumes here

Marked as spam
Posted by (Questions: 2, Answers: 477)
Answered on February 1, 2013 2:40 am
EyeOnTesting

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

X
Scroll to Top