【问题标题】:Firefox Error: "Your connection is not secure" while launching driver with Selenium 3.0.1 using JavaFirefox 错误:使用 Java 使用 Selenium 3.0.1 启动驱动程序时出现“您的连接不安全”
【发布时间】:2017-03-20 22:20:54
【问题描述】:

我的 Firefox 版本是 46.0.1,Selenium 版本是 3.0.1。 我收到错误:

您的连接不安全

在执行以下代码时:

    @Test
public void test() {
    ProfilesIni profile = new ProfilesIni();
    FirefoxProfile ffProfile = profile.getProfile("newCretedProfile");
    ffProfile.setAcceptUntrustedCertificates(true);
    ffProfile.setAssumeUntrustedCertificateIssuer(false);
    System.setProperty("webdriver.gecko.driver", "D:\\SELENUIUM\\Drivers\\geckodriver.exe");
    FirefoxDriver driver = new FirefoxDriver(ffProfile);
    driver.get("http://www.google.com");
    driver.quit();
}

我创建了新的 firefox 配置文件并按照此url 中的步骤操作

但是,当我启动任何网站时,它仍然无法正常工作并给我同样的错误。

【问题讨论】:

  • 你能提供你得到的错误信息吗?
  • 嗨@ChristianGrabowski 我收到了这个异常:org.openqa.selenium.WebDriverException: Error loading page

标签: java selenium firefox ssl geckodriver


【解决方案1】:

下载Firefox 55 beta并设置

capabilities.setCapability("acceptInsecureCerts", true);

这是适用于 Firefox 55 beta 的代码:

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setBrowserName("firefox");
capabilities.setCapability("acceptInsecureCerts", true);
RemoteWebDriver driver = new RemoteWebDriver(Environment.remoteWebDriverURL, capabilities);

【讨论】:

  • 同样,我也做了new FirefoxDriver(new FirefoxOptions { AcceptInsecureCertificates = true })
【解决方案2】:

对于 FF v53+ 和 Se 3.x(2017 年夏季),2017 年(5 月?)之前的建议不再适用。

have to use Marionetteset capability to True

我花了几天时间整理出所有陈旧过时的建议,免费提供给你。 :-)

【讨论】:

    【解决方案3】:

    我已经尝试过这种方法,对我来说效果很好。

    按照以下步骤创建新的 Firefox 配置文件。

    1. 关闭所有 Firefox 窗口
    2. 在“运行”对话框中,输入:“firefox.exe -p”,然后单击“确定”。
    3. 点击“创建配置文件”
    4. 为您的新配置文件创建一个名称(例如 Selenium)
    5. 点击“选择文件夹”
    6. 选择容易找到的位置,例如“C:\NewFirefoxProfile”
    7. 点击完成
    8. 现在选择新创建的配置文件后,启动 Firefox。打开您收到“安全连接问题”的特定网址,接受此配置文件的 SSL 证书。

    现在使用新创建的 firefox 配置文件运行您的 selenium 测试。根据您的要求修改以下代码。

    System.setProperty("webdriver.firefox.marionette","D:\\SELENUIUM\\Drivers\\geckodriver.exe");
    ProfilesIni profile = new ProfilesIni();    
    FirefoxProfile myprofile = profile.getProfile("C:\\NewFirefoxProfile");//location of your new firefox profile 
    WebDriver driver = new FirefoxDriver(myprofile);
    driver.get("https://cacert.org/");
    

    【讨论】:

      【解决方案4】:

      如果您想在带有 Selenium 3.0 的 Firefox 上运行测试,请将 Firefox 驱动程序功能“marionette”设置为 false。

          @Test
      public void test() {
          DesiredCapabilities d = new DesiredCapabilities();
          d.setCapability("marionette", false);
          WebDriver driver = new FirefoxDriver(d);
          driver.get("http://www.google.com");
          driver.quit();
      }
      

      【讨论】:

        【解决方案5】:

        geckodriver/Marionette 似乎还不支持它。

        您可以查看以下错误以获取更多信息:-

        https://github.com/mozilla/geckodriver/issues/93

        https://bugzilla.mozilla.org/show_bug.cgi?id=1103196

        【讨论】:

          猜你喜欢
          • 2017-03-20
          • 2018-07-19
          • 2016-04-04
          • 2014-01-03
          • 1970-01-01
          • 2017-05-08
          • 1970-01-01
          • 1970-01-01
          • 2018-12-31
          相关资源
          最近更新 更多