Problem
In my selenium grid setup, my session requests (which wait for empty slots to become available) time out before hitting newSessionWaitTimeout because they click on the timeout of the RemoteWebDriver command.
More details
I sometimes have more tests that I tried to run than the available slots on my nodes. This is supposed to be excellent , as tests trying to get a new session in an available slot get queued until the slot becomes free. I see how this happens correctly in my grid console (example below).
3 requests pending slot release. Features [{browserName = chrome, javascriptEnabled = true, version =, platform = ANY}] Features [{browserName = chrome, javascriptEnabled = true, version =, platform = ANY}] Features [{browserName = chrome, javascriptEnabled = true, version =, platform = ANY}]
However, this request timeout after the webdriver command timeout period, effectively ignores the newSessionWaitTimeout setting. My newSessionWaitTimeout set to -1 by default to allow undefined slot wait. The default webdriver command timeout is 60 seconds .
OneTimeSetUp: OpenQA.Selenium.WebDriverException: An HTTP request to a remote WebDriver server for the URL http: // {myHubIP}: 4444 / wd / hub / session expires after 60 seconds. ----> System.Net.WebException: operation completed; Exception does not have stacktrace
I can increase the driver timeout to some large amount, which is longer than my tests may need to wait for the slot to be received, but this will affect every command the driver executes. It seems impractical to basically eliminate the command timeouts to make sure my tests are not a timeout, but just wait for an open slot, especially when there is a specific parameter that should handle a timeout for a wait session.
So, I feel that somehow something is missing ...
Testing / Compliance
I tested to make sure my newSessionWaitTimeout really works by resetting the value under the 60 second timeout that I saw (resetting it to 10 seconds). Performing this when starting more tests than open slots, I got the expected error after 10 seconds, right on the replica.
System.InvalidOperationException: Error while forwarding a new session. A timeout request waiting for node to appear. in OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError (response response) in OpenQA.Selenium.Remote.RemoteWebDriver.Execute (String parameters driverCommandToExecute, Dictionary`2) in OpenQA.Selenium.RemoteDreapwame .Selenium.Remote.RemoteWebDriver..ctor (ICommandExecutor commandExecutor, ICapabilities wishCapabilities) in OpenQA.Selenium.Remote.RemoteWebDriver..ctor (Uri remoteAddress, ICapabilities wishCapabilities)
Thus, I can see that newSessionWaitTimeout working fine if this limitation is really reached.
Running the same test with newSessionWaitTimeout either below 0 (undefined wait), or anything above the driver command timeout (60 seconds by default) never gets into the above error because the request expires first. Instead, an error appears that I specified in the Overview section above.
Now, if I increase the timeout of RemoteWebDriver, I see that it is a timeout that I press, waiting for new sessions. For example, if I initialize my RemoteWebDriver using new RemoteWebDriver(new Uri($"http://{myHubIP}:4444/wd/hub"), capabilities, TimeSpan.FromMinutes(3)); , then I get the error:
OneTimeSetUp: OpenQA.Selenium.WebDriverException: An HTTP request to a remote WebDriver server for the URL http: // {myHubIP}: 4444 / wd / hub / session expires after 180 seconds. ----> System.Net.WebException: operation completed; Exception does not have stacktrace
Again, if I pick this value enough (it may take a lot if I have a lot of tests to run), it solves the problem with my waiting sessions, but now all the driver commands run the risk of hanging for a very long time, Any ideas on how do it right (it seems wrong)?
I am using Selenium WebDriver and standalone server 3.0.1