Forum Discussion

CraigB's avatar
CraigB
Contributor
5 years ago
Solved

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?

  • 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)

5 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    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.

    • CraigB's avatar
      CraigB
      Contributor

      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.

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        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)