Forum Discussion

georgios_vasila's avatar
georgios_vasila
New Contributor
11 years ago

Call refresh() automatically when "Unable to find the object..." error occurs

Hi,

I am fairly new to testcomplete and I would like a hint on how to proceed on the below issue. I face in several test the "Unable to find the object..." error. In order to avoid it, I call the refresh method for that object just before the action which returns the error.



The question is if there is any way to do the refresh every time the error occurs like the usage of an event handler. By that I will avoid to call the refresh manually before the "problematic" action but it will be called automatically when such an error occurs



Thanks in advance

George





3 Replies

  • Hi George,

    Do you know what is happening when the error happens?

    Some functions have a refresh as a parameter, such as the Find() method has the 4th parameter as refresh.



    The error may also occur becuase the UI hasn't finished being created.  You could experiment with using a delay, aqUtils.delay(1000).  If that works then maybe you need to look at writing code to check to see if the object exsists before you use it.

    I have this problem with one of our testing environments as it is very slow.
  • Hi Adrian,

    Thanks for your reply. Till now Refresh() does the job however what I was wondering is if there is a mechanism to do this every time such an error occurs in order to avoid adding it manually in each test before the action where the error appears
  • I can't think of any way to achieve what you want.

    What I would consider doing is:


    • Where the refresh parameter exists in a command or function - use it.


    • For all other commands or functions, create a reusable function to run for it, which includes the refresh() call.