How to control time taken to check if an object Exist or no when using the method Exists
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Set Project -> Properties -> Playback -> Auto-wait timeout value to 2000
or use Options.Run.Timeout = 2000 to control timeouts programatically.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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; }
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
