【问题标题】:Selenium Grid in Java: org.openqa.selenium.SessionNotCreatedException: invalid argument: can't kill an exited processJava中的Selenium Grid:org.openqa.selenium.SessionNotCreatedException:无效参数:无法终止已退出的进程
【发布时间】:2020-02-22 14:28:30
【问题描述】:

我想用 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

【问题讨论】:

    标签: java selenium selenium-grid


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      在初始化 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());
      }
      

      【讨论】:

      • 它仍然抛出完全相同的异常。
      • 我还尝试在节点上设置路径变量:chmod u+x geckodriver AND export PATH=$PATH:/PATH_OF_GECKO/geckodriver
      • 能否确保非root用户也有访问geckdriver的可执行权限?
      • 权限为:-rwxrwxrwx
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-09-10
      • 2020-06-11
      • 1970-01-01
      • 2019-03-03
      相关资源
      最近更新 更多