0

We're using Selenium's Python bindings at work. Occasionally I forget to put the call to WebDriver.quit() in a finally clause, or the tear down for a test. Something bad happens, an exception is thrown, and the session is abandoned and stuck as "in use" on the grid.

How can I quit those sessions and return them to being available for use without restarting the grid server?

lagweezle
  • 516
  • 5
  • 12
  • Why not inherit from a base test fixture that always calls `.quit` in it's `teardown`? You don't ever have to worry about it then. – Arran Jan 16 '14 at 18:52
  • @Arran [tearDown in unittest should be executed regardless of result in setUp](http://bugs.python.org/issue5538) is expected once you've had to deal with it, or read/remember [TestCase.tearDown()'s description](http://docs.python.org/2/library/unittest.html#unittest.TestCase.tearDown) very carefully. That is somewhat of an aside, though, as Selenium isn't always used in a test. We use it for task automation, and it isn't uncommon for me to use it in an interactive Python session and completely forget to clean up after myself. – lagweezle Jan 16 '14 at 21:12

2 Answers2

1

While quitting in an ensure/finally block would be the safest option, configuring the idle timeout for your browser session would be a good safety release. See the section on timeouts in the Grid 2 wiki page:

https://code.google.com/p/selenium/wiki/Grid2

nirvdrum
  • 2,319
  • 17
  • 26
0

You can restart the node instead of the server.

Major
  • 455
  • 1
  • 5
  • 15