How to modify the waitForObject() timeout

How to modify the waitForObject() timeout

Troubleshooting a script can be long and exhausting especially if there are objects which can not be found. Fortunately, we can adjust the timeout duration for waitForObject to save us some time.

By default the duration of waitForObject is 20000 milliseconds (20 seconds), which looks like this:

waitForObject(names.myObject)

 

During the given time Squish will check if the object can be located, is visible and enabled. If this is the case, the script continues otherwise returns an error and stops.

How to adjust the waitForObject timeout?

To change a single waitForObject occurrence you need to specify an alternate duration in milliseconds:

waitForObject(names.myObject, 1000)

 

In the example above, waitForObject has a maximum duration of 1000 milliseconds (1 second) until the script will continue or abort.

How to set the default value, on a Test-Suite basis?

As of Squish 6.4, it is now possible to set it on a test suite basis, from SquishIDE, in the Test Suite SettingsTest Settings tab. From there, you can set the waitForObjectTimeout to something different, in milliseconds.

What about Squish 6.3?

You can place an xml file called config.xml into the test suite directory (next to suite.conf) and set the value on a test suite basis. In the example below, it is set to 2 seconds (2000 milliseconds) .

<testconfig version="1.0">
  <information> <summary/> <description/> </information>
  <testsettings>
    <waitForObjectTimeout>2000</waitForObjectTimeout>
  </testsettings>
</testconfig>

 

Find out more about waitForObject in our Documentation.