Forum Discussion

ASV's avatar
ASV
Contributor
13 years ago

Waiting VBObject

Hi

I write this code



1.Dim t, Timeout


2.t = 0


3.

4.    Do While (Not wMDIClient.VBObject("frmPttel").VisibleOnScreen) and t < Timeout


5.        BuiltIn.Delay(1000)


6.       t = t + 1


7.    Loop



when TC comes in line 4, it's pausing some seconds. I don't want that pause(I think this is a problem).Anybody can help me what to do avoid this problem.

Thanks.

5 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    The pause is by design, especially if TestComplete needs to determine if the object exists.  There's a setting under Tools | Current Project Properties for "Auto Wait Timeout" which indicates how long to wait for an object.



    If you want to have more control over that, try changing your line 4 to the following



    Do While (Not wMDIClient.WaitVBObject("frmPttel", 0).VisibleOnScreen) and t < Timeout 





  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Whoops... accidental double post... ignore this post (okay... how do you ignore a post that tells you to ignore itself?  PARADOX!)
  • ASV's avatar
    ASV
    Contributor
    Hi Robert

    Thanks for your response.

    I want to fix how many time is required that VBObject("frmPttel") becomes visible.

    I write this code



    1.Dim t, Timeout


    2.t = 0


    3.    

    4.    Do While (Not wMDIClient.WaitVBObject("frmPttel", 0).Exists) and t < Timeout


    5.        BuiltIn.Delay(1000)


    6.        t = t + 1


    7.    Loop

    8.

    9.     Do While (Not wMDIClient.WaitVBObject("frmPttel", 0).VisibleOnScreen) and t < Timeout


    10.        BuiltIn.Delay(1000)


    11.        t = t + 1


    12.   Loop




    but after one loop (t=1), TC pauses in line 4.

      


     
  • ASV's avatar
    ASV
    Contributor
    I forgot to say that writing only this code



    1.Dim t, Timeout


    2.t = 0

    3.

    4.        Do While (Not wMDIClient.WaitVBObject("frmPttel", 0).VisibleOnScreen) and t < Timeout


    5.            BuiltIn.Delay(1000)


    6.            t = t + 1


    7.        Loop

     

    I have a Log error "The object does not exist" and TC pauses until VBObject("frmPttel") becomes in existence.
  • Hi,



    Is there a reason to reobtain your object on each loop iteration? If you want to find out how long it takes your object to appear, why not use code like this?



    Dim obj, timeout, t

    t = GetTickCount

    timeout = ' the waiting time in milliseconds

    Set obj = wMDIClient.WaitVBObject("frmPttel", timeout)

    If obj.Exists Then

    Do While Not obj.VisibleOnScreen

    obj.Refresh

    If GetTickCount - t > timeout Then

    ' Do something here like posting an error

    Exit Do

    End If

    Loop

    End If



    t = GetTickCount - t

    Log.Message("Total time: " & t)