Java 中的 Selenium Grid:org.openqa.selenium.SessionNotCreatedException:参数无效:无法终止退出的进程

Selenium Grid in Java: org.openqa.selenium.SessionNotCreatedException: invalid argument: can't kill an exited process

我想在 Java 中编写一个 Selenium Grid 应用程序。

http://localhost:4444/grid/console 上说节点已连接到集线器。

在客户端我想写如下:

try {
        DesiredCapabilities capability = DesiredCapabilities.firefox();

        WebDriver driver = new RemoteWebDriver(new URL("http://IP of Hub:4444/wd/hub"), capability);
        capability.setBrowserName("firefox");
        driver.get("https://www.google.com");

} catch (MalformedURLException ex) {
        System.err.println("URL Exception: "+ex.getMessage());
}

不幸的是,运行 客户端应用程序抛出以下异常:

    Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: invalid argument: can't kill an exited process
...
Driver info: driver.version: unknown

在初始化 webdriver 实例之前提供 geckodriver 路径,

try {
     DesiredCapabilities capability = DesiredCapabilities.firefox();
     System.setProperty("webdriver.gecko.driver", "/PATH_OF_DRIVER/geckodriver.exe");
     driver = new RemoteWebDriver(new URL("http://Hub_IP/wd/hub"), capability);
     capability.setBrowserName("firefox");
     driver.get("https://www.google.com");

} catch (MalformedURLException ex) {
     System.err.println("URL Exception: "+ex.getMessage());
}

解决方案:Linux(节点)中的 geckodriver 有问题。 我在 Windows PC 上添加了一个节点,它工作正常。