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.