cancel
Showing results for 
Search instead for 
Did you mean: 

How to have a test wait for a window to appear?

SOLVED
Contributor

How to have a test wait for a window to appear?

Hi

 

When starting up an application I need to wait for the login window to appear.  And then, after that I need to wait for the main window.  Etc.  TestComplete offers a function that, from it's name and documentation, ought to be just what I need - wait x milliseconds for a window with a given title to appear.  Except that it doesn't bother to wait the time I specify.  It appears to be waiting 10 seconds regardless of how long I tell it to wait.  I've tried all the way up to 5 minutes and it just ignores it.

So, is the only way to get a wait of x seconds to wait over and over in a loop?  I've actually got a test project that does exactly this because it was the only way to get it to work - it uses the process returned from calling Run on the TestedApp and calls WaitWinFormsObject on it over and over.  But that was in TestComplete 12 and since there's WaitWindow I was hoping that'd be an option.  If it is an option, how can I make that work, either using a loop or without?  Even with an attempt at a loop, it seems WaitWindow is stopping the test if it doesn't find the window I'm wanting (it doesn't return a stub object as claimed by the documentation).  Or should I just ignore WaitWindow and use the method I used in the other test project?

1 ACCEPTED SOLUTION

Accepted Solutions
Community Hero

Re: How to have a test wait for a window to appear?

Question:

Is <Mapped window name> the window you're waiting for?  If so... that's kind of what I was saying about the implementation of WaitWindow.

If this is the case, the better way of doing what you want is this.

Aliases.<TestedApp>.WaitAliasChild(<Mapped window name>, 30000)

 

If you want to still use WaitWindow, you would need to know it's direct parent.  So, the code would be

 

Aliases.<TestedApp>.<mapped window of parent object>.WaitWindow('*', <insert titel here>, -1, 30000)


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
5 REPLIES 5
Community Hero

Re: How to have a test wait for a window to appear?

How have you implemented the code?  Can you copy paste, please?  It sounds like it's waiting for the object to be present before it calls "WaitWindow" which seems that you're not implementing the method properly.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Contributor

Re: How to have a test wait for a window to appear?

There's no wait until the call to WaitWindow, so there isn't any object being waited on.

I've tried variations on 
Aliases.<TestedApp>.<Mapped window name>.WaitWindow(

"*",
"<insert title here>",
-1,
30000),

 

including not having the -1, having up to 300000 instead of 30000, putting the class name in for WndClass.  Someone did manage to get this working in v12.60 without the -1, but those calls stopped working in v14.

Community Hero

Re: How to have a test wait for a window to appear?

Question:

Is <Mapped window name> the window you're waiting for?  If so... that's kind of what I was saying about the implementation of WaitWindow.

If this is the case, the better way of doing what you want is this.

Aliases.<TestedApp>.WaitAliasChild(<Mapped window name>, 30000)

 

If you want to still use WaitWindow, you would need to know it's direct parent.  So, the code would be

 

Aliases.<TestedApp>.<mapped window of parent object>.WaitWindow('*', <insert titel here>, -1, 30000)


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Highlighted
Contributor

Re: How to have a test wait for a window to appear?

Thanks.  I assumed this would work in v14 since it was apparently working in v12.6 - I inherited this code from someone who wrote it using v12.6.  I've managed to get it working by waiting on the app itself.

Community Hero

Re: How to have a test wait for a window to appear?

As an explanation, V 14.x has had some adjustments made to the engines for object identification to, actually, improve performance.  Part of that is to do a better job of being strict on object identification hence why you're getting the 10 second wait that you were... because you were attempting to use the object to wait for the object (calling the WaitWindow method on the object for which you were waiting).


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
New Here?
Join us and watch the welcome video:
API Testing Mistake #2
APITestingMistake#2
Top Kudoed Authors