我的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
的步骤操作然而,当我启动任何网站时,它没有工作并给我同样的错误。
答案 0 :(得分:4)
下载Firefox 55测试版并设置
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);
答案 1 :(得分:2)
我尝试过这种方法,但对我来说效果很好。
按照以下步骤创建新的Firefox配置文件。
现在使用新创建的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/");
答案 2 :(得分:2)
使用FF v53 +和Se 3.x(2017年夏季),2017年(5月?)之前的建议不再适用。
您have to use Marionette和set capability to True。
我花了几天时间来解决所有旧的和过时的建议,免费提供。 : - )
答案 3 :(得分:1)
geckodriver / Marionette似乎还不支持它。
您可以查看以下错误以获取更多信息: -
答案 4 :(得分: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();
}