Forum Discussion

vthomeschoolmom's avatar
vthomeschoolmom
Super Contributor
13 years ago

WaitVBObject problem

I have a line of script



set frmStatus = Sys.Process("MyApp").VBObject("frmMain").Window("MDIClient", "", 1).WaitVBObject("frmCust", 3000)

set grdStatus = frmCust.WaitVBObject("GridEXCustomers", 2000)



On the second line, Test complete reports waiting for GridEXCustomers. Forever. I have to kill the app to get out.



So off I go to the help file...



A call to any WaitXXXObject method causes the object tree to refresh. To update object data, TestComplete may call some of object’s native methods that are accessible only from the application’s thread. When the thread is busy, TestComplete tries to call those methods during some pre-defined time (one second) thus delaying the refresh. There could be several attempts to get the object’s data which could result in a noticeable difference from the Timeout value.



I cannot imagine the object tree is being refreshed. And... busy thread? How do I even know? I use the exact same script elsewhere and the grid is found easily.



Help please!


6 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    That's a VERY good question, Lane.



    Just on the surface, it doesn't look like anything strange would be going on.



    However, the line above the call to the grid you're looking for frmCust and you're assigning it to the variable frmStatus.  The grid line you're doing a call of WaitVBObject off of frmCust and assigning it to gridStatus.



    Is this your intent to assign the VBObjects to those variables?



    Additionally, you're waiting up to 3 seconds for frmCust to appear... when you get to your Grid call, are you certain 3 seconds was long enough?



    A "best practice" I always use is that, when using one of those "WaitXXXXObject" calls, to follow it up first with an "if it exists" check.  It's entirely possible that, in this one instance of your script code, frmCust may not return within 3 seconds and you may need to wait longer.  You MIGHT be getting caught in some sort of internal update where frmCust may still be in the process of resolving some sort of internal method before you get to the Grid.



    Double check to see if frmCust exists before you go further.  Something like:



    set frmCust = Sys.Process("MyApp").VBObject("frmMain").Window("MDIClient", "", 1).WaitVBObject("frmCust", 3000)

    if frmCust.Exists then

        set grdStatus = frmCust.WaitVBObject("GridEXCustomers", 2000)

    else

        Log.Error("The form didn't exist when I wanted it to")

  • It is our company policy to mask the real names of things on forum posts! I simply was not careful enough!



    :)
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Gotcha. :-)



    In any case, the best practice, I believe, still applies.  Check for the existence of frmCust before you try and search for child objects off of it.  
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Don't ya now?  Those are the kinds of problems I hate the most, especially when testing an app.  I go through it 5 or 6 times, reproducing a really nasty bug, call the developer over and say, "Let me show you this"... and then it works perfectly...  



    Or, you report a bug, and then the next build of the software the bug is not present any more and the developer says "I didn't change anything".



    Is a bug still a bug if you cannot reproduce it anymore? ;-)