Forum Discussion

rushikesh's avatar
rushikesh
Contributor
7 years ago
Solved

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.

 

 

 

 

 

  • baxatob's avatar
    baxatob
    7 years ago

    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;
    
    }

     

4 Replies

  • baxatob's avatar
    baxatob
    Community Hero

    Hi,

     

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

     

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

    • rushikesh's avatar
      rushikesh
      Contributor

      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.

      • baxatob's avatar
        baxatob
        Community Hero

        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;
        
        }