- 02 Mar 2023
- 2 Minutes to read
- Print
- DarkLight
Idle Timeout for Appium
- Updated on 02 Mar 2023
- 2 Minutes to read
- Print
- DarkLight
Objective of this document
This help guide will help you with the steps to address the idleTimeout use cases.
Why is it used?
We use the timeout feature to terminate the Appium session if any request is not coming within a particular time interval.
It's better to use any wait statements in the script. However, we would advise you to avoid the hardcore wait.
And in case you need to use any hardcore wait in your code, please ensure that the sleep value is always less than IdelTimeout else the session will terminate as no request will come with that time period to the server.
About Default idleTimeout
pCloudy sends the idleTimeout when a testing session is left idle for more than 60 seconds, since the default timeout value is set for 60 seconds. You can change this by setting any timeout value between 20 to 600 seconds to the idleTimeout capability.
Steps
- Call the driver.quit Appium command at the end of your test script to release the device after the default 60 sec. In case, you have not used driver.quit, the device will release according to the set time of idleTimeout capability.
- Refer to the script commands in the table below to call the driver.quit command in the respective language of your test script.
Language | Script |
---|---|
Java | driver.quit(); |
Node.js | driver.quit(); |
C3 | driver.Quit(); |
PHP | $driver->quit(); |
Python | driver.quit() |
Ruby | driver.quit |
Perl | $driver->quit(); |
When to use the idleTimout Capability?
- If the user has given the hardcode wait value more than 60sec; the following capability needs to be added.
capabilities.setCapability("idleTimeout",70-600 secs);
If the user has given the hardcode wait value less than 60sec; the use of the idleTimeout capability is not mandatory.
If the user has given any explicit wait; which takes more than 60sec. the idleTimeout capability needs to be added. As shown in the example below.
capabilities.setCapability("idleTimeout",70-600 secs);
The advantage of Idle timeout
For some reason, if the test execution gets stopped before itself, then the device will release straight after that booking time. However, If we use IdleTimeout in our script then the device will release after that time which we provide in idleTimeout.
- if someone is using hard coded wait for more than 10mins and provide IdleTimeout as max 600 sec device will release after the 600 secs.
- if you are using any hardcode wait and if sleep time is greater than 60sec you have to use idleTimeout capability and the value of that capability should be greater than your sleep time.
- newCommandTimeout capability value always should equal or more than the idleTimeout value.