selenium - UnreachableBrowserException : Could not start a new session. 可能的原因是使用 Selenium Grid 的远程服务器的地址无效

标签 selenium selenium-webdriver webdriver selenium-grid remotewebdriver

打开新驱动程序窗口时出错:

org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.

服务器日志:
Forwarding newSession on session null to remote

我在 linux 上运行以下代码:
driver= new RemoteWebDriver((new URL( "http://"+ip+":5555/wd/hub")), capability);

我的中心节点已经启动并运行。那为什么我会收到此错误。

最佳答案

这个错误信息...

org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.

和服务器日志...
Forwarding newSession on session null to remote

...暗示 Selenium Grid Hub/Selenium Grid Node 未正确启动/启动。结果是 null session被转发到 RemoteWebDriver。

关于您使用的二进制文件版本的更多信息,如 Selenium 服务器/客户端、WebDriver 变体/version 和 WebBrowser 变体/version 以及您用于启动 Selenium Grid Hub/Selenium Grid Node 的命令将有助于我们以更简单的方式调试您的问题。

但是,由于以下多种因素,可能会发生此问题:
  • 您正在使用 uri 5555/wd/hub ,因此请确保在端口 上启动 Selenium Grid Hub 5555 .
  • 您可以选择更换 capability带有 Options 实例的参数类如下:
    DesiredCapabilities caps = new DesiredCapabilities();
    caps.setCapability("browser", "chrome");
    //seting the required capabilities
    ChromeOptions options = new ChromeOptions();
    options.merge(caps);
    WebDriver driver = new RemoteWebDriver((new URL( "http://"+ip+":5555/wd/hub")), options);        
    
  • 您可以在 Remote WebDriver UnreachableBrowserException: Could not start a new session 中找到相关讨论。
  • 由于您使用的二进制文件的版本不匹配,GeckoDriver/Selenium/Mozilla 经常会出现此问题。作为经验法则,始终遵循 GeckoDriver, Selenium and Firefox Browser compatibility chart 中的配置矩阵

  • supported_platforms_geckodriver_24
  • 您可以在 WebDriverException: Message: newSession with GeckoDriver Firefox v65 and Selenium through Python 3.7 中找到相关讨论。
  • 关于selenium - UnreachableBrowserException : Could not start a new session. 可能的原因是使用 Selenium Grid 的远程服务器的地址无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54824977/

    相关文章:

    c# - 如何检测页面是否正在执行javascript

    java - 如何为selenium java代码添加循环条件

    java - 等待图表刷新,selenium Java

    selenium - 如何更改允许站点保存和读取 cookie 数据(推荐)和/或阻止第三方 cookie

    javascript - 使用滚动查找所有元素

    ruby - watir splash 中的页面对象——如何确保正确的页面对象被实例化

    mobile - 在 ChromeDriver 中模拟移动设备

    java - 让 Selenium 等待文件下载完成

    html - 使用 xpath 查找具有特定内容的跨度

    python - Selenium:模拟人类打字行为