my thoughts on test automation
Timeouts in Selenium Webdriver
If you’re chasing timeout-related issue with your Selenium tests, it’s good to know what types of timeouts you can play with.
Timeouts set within your code
There are 3 timeouts which can be set under driver.manage().timeouts():
- Selenium implicit waits are managed by implicitlyWait(). This setting will manage how long Selenium waits for element to appear before throwing NoSuchElementException.
- You can specify non-default value for pageLoadTimeout(). This parameter manages wait times for loading page by browser before throwing TimeoutException.
Timeouts set in Selenium Grid environment
If you run your tests in a Grid, there are a few timeouts which can be of your interest. Those are specified as command line parameters when running selenium-server-standalone-.jar:
- newSessionWaitTimeout, which defaults to no timeout. If specified, new test must be allocated an execution node within that time. If it’s not, an exception is thrown: org.openqa.selenium.WebDriverException: Error forwarding the new session Request timed out waiting for a node to become available.
- timeout, which specifies how long particular test which started execution can remain idle, before terminating client session. With this timeout, test which hangs without any communication with browser will not utilise execution node for ever. This is the exception you can find in your stack trace: org.openqa.selenium.WebDriverException: Session  was terminated due to TIMEOUT.
- browserTimeout, which is considered to be a safety net for timeout above.