1

There seems to be a lack of documentation about this (or at least I can't find it). I want to eventually have a load of Selenium tests running on Jenkins and using a Selenium Grid2. When I am writing my tests I would like to know how I tell the hub that I have finished with the WebDriver instance I am using. Should I call webDriver.close() or webDriver.quit()? What happens when I ask for a RemoteWebDriver and none are available, is there a timeout period that I can set?

Or can anyone point me to some documentation/blog about this, everything I've found tells you how to get stuff up and running but stops there?

1 Answer 1

3

Use webDriver.quit() to close the browser instance (session) gracefully. webDriver.stop() is likely to cause exceptions (I tell you from my own experience, though you also can find a lot of discussions about it here).

You can see this and this for reference. Be careful to distinguish between Selenium Grid 1 and Selenium Grid 2.

To better understand how it works, it helps to have a look at the WebDriver's code.

If you ask for a RemoteWebDriver (configured for the requested environment) and none is available, the hub will put the request on hold, till one gets free. If the hub don't "know" about any node with the requested environment, you will get something like this:

Caused by: org.openqa.selenium.WebDriverException: Error forwarding the new session cannot find : {platform=WINDOWS, javascriptEnabled=true, browserName=chrome, version=25.0.1312.56}

the test will be not executed and will fail.

As for timeouts configuration, this might help.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.