Ask a Question

How to control time taken to check if an object Exist or no when using the method Exists

SOLVED
rushikesh
Contributor

How to control time taken to check if an object Exist or no when using the method Exists

Hi,

 

I am using below code to check if dialog present in application is still available or no after clicking on OK button.

 

page2_5AxisEndConditions.Tick.Click();
if (page2_5AxisEndConditions.Exists)
{


dlgCAMWorksMessage.btnOK.Click()
Log.Error("Feature could not be inserted")
page2_5AxisEndConditions.Close()

 

 

This code works correctly.

However, if dialog (page2_5AxisEndConditions) does not close on clicking OK it waits for 10 sec, while executing the Exists method. I want it to wait only for 2 sec as this code is going to be used again and again and this will slow my script execution.

How to control this wait time through code only for this dialog? Or there is any other method to do this ?

 

Any help is appropriated. 

 

Regards,

Rushikesh Kadam.

 

 

 

 

 

4 REPLIES 4
baxatob
Community Hero

Hi,

 

Set Project -> Properties -> Playback -> Auto-wait timeout value to 2000

 

or use Options.Run.Timeout = 2000 to control timeouts programatically.

Hi, I suppose that will set Timeout for entire project as 2 sec. I want 2 sec only when particular code is running, as rest all object will require more Timeout.

You can implement some checkObjectExists() method:

 

 

 

function checkObjectExists(object, timeout) {

  Options.Run.Timeout = timeout;
  if object.Exists {
    do_something();
  }
  else { 
    do_something_else();
  }
  Options.Run.Timeout = 10000;

}

 

IMO it would be much safer to use a WaitProperty so you're not adjusting the global wait.

function checkObjectExists(object, timeout) {

 if (!object.WaitProperty("Exists",true,timeout)) {
    do_something();
  }
  else { 
    do_something_else();
  }
}

 

 


Thanks,
Carson

Click the Accept as Solution button if my answer has helped
cancel
Showing results for 
Search instead for 
Did you mean: