Reputation: 31
I am getting the below WebDriver exception when trying to navigate to a URL (just simply to Google) using Selenium Grid running locally.
org.openqa.selenium.WebDriverException: Session [null] not available and is not among the last 1000 terminated sessions.
I am running selenium-server-standalone-3.141.59.jar
on my desktop in the Grid configuration with one hub and one node. In two different cmd windows I start the hub with -role hub
, and then the node with -role node -hub http://localhost:4444/grid/register
. All seems to start just fine.
Java code:
public void initialGridTest() throws Exception {
try {
System.setProperty("webdriver.chrome.driver", "D:\\SeleniumWebDrivers\\chromedriver.exe");
DesiredCapabilities capability = DesiredCapabilities.chrome();
RemoteWebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability);
driver.get("http://www.google.com");
String doodleText = driver.findElement(By.id("logo-doodle-image")).getText();
} catch (Exception e) {
System.out.println("e: " + e);
}
}
I have a simple test in a Java class running in IntelliJ that calls RemoteWebDriver
to navigate to Google. When I execute new RemoteWebDriver(...
in the code, I see my Java program connecting to the hub and the hub connecting with the node, and the node opens a new instance of Chrome. But when the program runs driver.get()
I get the WebDriverException
. I see in the node console that it has a session id, but for some reason the session is null in my Java code.
Upvotes: 3
Views: 5968
Reputation: 193338
This error message...
org.openqa.selenium.WebDriverException: Session [null] not available and is not among the last 1000 terminated sessions.
...implies that the Selenium Grid Node was unable to communicate with the Selenium Grid Hub.
As per the following discussions:
It seems this error stems out when:
Ensure that Selenium Grid Hub, Selenium Grid Node and the Client Process all of them uses the same version of Selenium client i.e. Selenium v3.141.59
Upvotes: 3