Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to increase Selenium grid session timeout?

While running my test, I need to have long delays (~40 seconds).

And I see, that Selenium session gets deleted during that time.

Please help: How can I configure session timeout to increase?

Here what I see in less, that 30 secs, after delay started in the Selenium node log:

INFO org.openqa.selenium.remote.server.DriverServlet - Session 7f5fffec-4882-4c4c-b091-c780c66d379d deleted due to client timeout

And after 40 seconds sleep, I'm getting this exception in my code:

org.openqa.selenium.remote.SessionNotFoundException

I tried to increase all possible timeouts. Here is how I start hub:

java -jar selenium-server-standalone.jar -role hub 
-hubConfig selenium_hub.json 
-nodeTimeout 61 
-remoteControlPollingIntervalInSeconds 180 
-sessionMaxIdleTimeInSeconds 240 
-newSessionMaxWaitTimeInSeconds 250 
-timeout 59

And here is selenium_hub.json:

{
  "host": null,
  "port": 4444,
  "newSessionWaitTimeout": -1,
  "servlets": [],
  "prioritizer":  null,
  "capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
  "throwOnCapabilityNotPresent": true,
  "nodePolling": 5000,
  "cleanUpCycle": 5000,
  "timeout": 60000,
  "browserTimeout": 60000,
  "maxSession": 5,
  "jettyMaxThreads": -1
}

No any timeouts configured on the nodes. Here is what I see in my Grid console:

browserTimeout : 60000
capabilityMatcher : org.openqa.grid.internal.utils.DefaultCapabilityMatcher
cleanUpCycle : 5000
host : null
hubConfig : /usr/local/selenium/config/selenium_hub.json
jettyMaxThreads : -1
maxSession : 5
newSessionMaxWaitTimeInSeconds : 250
newSessionWaitTimeout : -1
nodePolling : 5000
nodeTimeout : 61
port : 4444
prioritizer : null
remoteControlPollingIntervalInSeconds : 180
role : hub
servlets : []
sessionMaxIdleTimeInSeconds : 240
throwOnCapabilityNotPresent : true
timeout : 59000

I'm using Selenium 2.45

like image 264
Slavik Avatar asked Mar 26 '15 07:03

Slavik


People also ask

What is the default timeout for Selenium Grid?

-timeout 30 (300 is default) The timeout in seconds before the hub automatically releases a node that hasn't received any requests for more than the specified number of seconds. After this time, the node will be released for another test in the queue.

What is browser timeout in the grid?

timeout - This value represents how long should the Grid wait before it treats a particular test session (a particular running test case) as stale, so that that particular test session can be cleaned up and the slot released so that some other test case can basically execute on the node.

How do you limit the maximum number of nodes in selenium grid?

There is no fixed selenium grid limit, but you need to have in mind: Only one InternetExplorer can run on a single node. This is browser limitation, though, not Selenium.

How does Python handle session timeout in selenium?

If Current time - Test start time >= 30 minute s then check if system logout and if yes then login again. but for this question is same like I have to call it in either every method or in some specific methods to check every time if logout or not.


1 Answers

I finally figured it out!

Solution is actually very easy: nodes needs to be restarted after configuration changed on the hub.

It is not really obvious:

When I changed configuration on the hub, then I restarted it. Node would re-register with the hub automatically. Then looking at the console, I can see new configuration parameters taking effect. Even more, as I'm looking at the node configurations, I see same parameters changed on the nodes. That's misleading! Because even though nodes re-registered, but their configuration has NOT been changed. It only changes, when node is restarted, too. I think, this is Selenium bug - node should re-configure during re-registration.

like image 61
Slavik Avatar answered Nov 15 '22 15:11

Slavik