Forum Discussion

Rakeshyadav09's avatar
Rakeshyadav09
Occasional Contributor
6 years ago
Solved

This Operation was canceled because the method invoke timeout has expired.

Hello All,

 

I am using the following line of code to dynamically wait for an object:

' waits until the Close button gets enabled
While hecrasExe.frmCompute.vbObject("cmdClose").Caption <> "Close"
Wend

But from last few days, the automation test failed a couple of times displaying the following error message in the log file:

This Operation was canceled because the method invoke timeout has expired.

 

Would someone please guide me what is the problem that is causing this issue, It is not happening everytime but you can say that it is happening 2 out of 10 times.

  • Hi,

     

    > But from last few days [...]

    a) What has changed these days? (Version of TestComplete, version of tested application, Windows updates, etc.)

    b) Did you provide exact code that is used in the production? If you are, then I would recommend to put a small delay to let system process events/changes. E.g.:

    While hecrasExe.frmCompute.vbObject("cmdClose").Caption <> "Close"

      Call Delay(500)
    Wend

     

    c) Instead of the above loop you may consider to use the .WaitProperty() method. I.e.:

    If (hecrasExe.frmCompute.vbObject("cmdClose").WaitProperty("Caption", "Close", 30000) Then

      ...

    Else

      ...

    End If

     

1 Reply

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    > But from last few days [...]

    a) What has changed these days? (Version of TestComplete, version of tested application, Windows updates, etc.)

    b) Did you provide exact code that is used in the production? If you are, then I would recommend to put a small delay to let system process events/changes. E.g.:

    While hecrasExe.frmCompute.vbObject("cmdClose").Caption <> "Close"

      Call Delay(500)
    Wend

     

    c) Instead of the above loop you may consider to use the .WaitProperty() method. I.e.:

    If (hecrasExe.frmCompute.vbObject("cmdClose").WaitProperty("Caption", "Close", 30000) Then

      ...

    Else

      ...

    End If