3

我的 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中的步骤操作

然而,当我启动任何网站时,它不起作用并给我同样的错误。

4

5 回答 5

4

下载 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);
于 2017-08-08T05:13:25.273 回答
2

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

必须使用 Marionette并将能力设置为 True

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

于 2017-06-01T17:40:02.997 回答
2

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

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

  1. 关闭所有 Firefox 窗口
  2. 在“运行”对话框中,键入:“firefox.exe -p”,然后单击“确定”。
  3. 点击“创建个人资料”</li>
  4. 为您的新配置文件创建一个名称(例如 Selenium)
  5. 点击“选择文件夹”</li>
  6. 选择容易找到的位置——比如“C:\NewFirefoxProfile”</li>
  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/");
于 2016-11-30T07:22:58.797 回答
1

geckodriver/Marionette 似乎还不支持它。

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

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

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

于 2016-11-07T16:52:03.800 回答
0

如果您想在带有 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();
}
于 2016-11-08T04:42:56.840 回答