【问题标题】:Exception in thread "main" org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary using webdriver.firefox.marionette线程“主”org.openqa.selenium.WebDriverException 中的异常:无法使用 webdriver.firefox.marionette 连接到二进制 FirefoxBinary
【发布时间】:2019-04-03 02:16:41
【问题描述】:
public class TestClass1 {
    public static void main(String[] args) {
        System.setProperty("webdriver.firefox.marionette","C:\\geckodriver.exe");

        WebDriver driver = new FirefoxDriver();
        driver.get("https://accounts.google.com/signin");

        driver.close();
        System.exit(0);
    }
}

这段代码的结果如下:

Exception in thread "main" org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary(C:\Program Files\Mozilla Firefox\firefox.exe) on port 7055; process output follows: 

      [
        {
          "id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}",
          "minVersion":"63.0","maxVersion":"63.*"
        }
      ],
      "targetPlatforms":[],
      "seen":true,
      "dependencies":[],
      "hasEmbeddedWebExtension":false,
      "userPermissions":null,
      "icons":{},
      "blocklistState":0,
      "blocklistURL":null,
      "startupData":null,
      "hidden":true,
      "location":"app-system-defaults"
    }

【问题讨论】:

    标签: selenium firefox selenium-webdriver webdriver geckodriver


    【解决方案1】:

    试试这个:

    1. 确保您的 FF 版本为 63(2018 年 10 月 30 日最新)
    2. 确保您的 selenium 版本是 3.14
    3. 确保您已下载最新的 geckodriver 0.23 (https://github.com/mozilla/geckodriver/releases)
    4. 确保 geckodriver.exe 位于 C:\\ 的根目录中(或更改以下路径)
    5. 使用:System.setProperty("webdriver.gecko.driver", "C:\\geckodriver.exe");

    如果不起作用,请尝试将您的 FF 降级到之前的 62 版本并试一试。

    仅供参考Difference between webdriver.firefox.marionette & webdriver.gecko.driver

    支持的版本: https://firefox-source-docs.mozilla.org/testing/geckodriver/geckodriver/Support.html

    【讨论】:

    • @JerryGeorge 如果您分享哪个步骤对您有帮助,这将对其他用户有所帮助......或者如果他们都没有帮助,请提供更多详细信息;)。
    【解决方案2】:

    在使用 Selenium 3.xGeckoDriverFirefox 时,您需要下载所需的最新版本 GeckoDrivermozilla/geckodriver 提取它并通过Key 通过System.setProperty() 行提及GeckoDriver 二进制文件的绝对路径 webdriver.gecko.driver 而不是 webdriver.firefox.marionette 如下:

    public class TestClass1 {
    
        public static void main(String[] args) {
    
        System.setProperty("webdriver.gecko.driver","C:\\path\\to\\geckodriver.exe");
        WebDriver driver = new FirefoxDriver();
        driver.get("https://accounts.google.com/signin");
        driver.quit();
        }
    }
    

    注意:始终在 tearDown(){} 方法中调用 driver.quit() 以优雅地关闭和销毁 WebDriverWeb Client 实例。 p>

    Supported Platforms

    下表显示了 geckodriver 版本、支持的 Firefox 版本和所需的 Selenium 版本之间的映射:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-11-03
      • 1970-01-01
      • 2012-11-10
      • 1970-01-01
      • 1970-01-01
      • 2018-12-31
      • 2017-10-30
      • 1970-01-01
      相关资源
      最近更新 更多