Firefox 错误:使用 Java 启动带有 Selenium 3.0.1 的驱动程序时“您的连接不安全”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40467460/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Firefox Error: "Your connection is not secure" while launching driver with Selenium 3.0.1 using Java
提问by Pratik Patel
My Firefox version is 46.0.1 and Selenium version is 3.0.1. I am getting error:
我的 Firefox 版本是 46.0.1,Selenium 版本是 3.0.1。我收到错误:
Your connection is not secure
您的连接不安全
while executing following code:
在执行以下代码时:
@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();
}
I have created new firefox profile and followed steps from this url
我创建了新的 firefox 配置文件并按照此url 中的步骤操作
Nevertheless it's not working and giving me same error while I launching any site.
然而,当我启动任何网站时,它不起作用并给我同样的错误。
回答by Sergey
Download Firefox 55 beta and set
下载 Firefox 55 beta 并设置
capabilities.setCapability("acceptInsecureCerts", true);
Here is my code that works for Firefox 55 beta:
这是我适用于 Firefox 55 beta 的代码:
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setBrowserName("firefox");
capabilities.setCapability("acceptInsecureCerts", true);
RemoteWebDriver driver = new RemoteWebDriver(Environment.remoteWebDriverURL, capabilities);
回答by Shoaib Akhtar
I have tried this approach and it worked well for me.
我已经尝试过这种方法,它对我来说效果很好。
Create new firefox profile by following below step.
按照以下步骤创建新的 Firefox 配置文件。
- Close all your firefox windows
- In the Run dialog box, type in: ‘firefox.exe -p' and then Click OK.
- Click “Create Profile”
- Create a name for your new profile(say Selenium)
- Click “Choose Folder”
- Pick location something easy to find — like “C:\NewFirefoxProfile”
- Click Finish
- Now after selecting newly created profile, start Firefox. Open the specific url you were getting 'Secure Connection Issue', accept SSL certificates for this profile.
- 关闭所有 Firefox 窗口
- 在“运行”对话框中,键入:“firefox.exe -p”,然后单击“确定”。
- 点击“创建个人资料”
- 为您的新配置文件创建一个名称(比如 Selenium)
- 点击“选择文件夹”
- 选择容易找到的位置——比如“C:\NewFirefoxProfile”
- 单击完成
- 现在选择新创建的配置文件后,启动 Firefox。打开您收到“安全连接问题”的特定 url,接受此配置文件的 SSL 证书。
Now use the newly created firefox profile to run your selenium test. Modify below code as per your requirement.
现在使用新创建的 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/");
回答by Peter M. - stands for Monica
With FF v53+ and Se 3.x (summer 2017), advice from before (May?) 2017 is no longer true.
使用 FF v53+ 和 Se 3.x(2017 年夏季),2017 年之前(五月?)的建议不再正确。
You have to use Marionetteand set capability to True.
Took me few days to sort out all old and obsolete advice, yours for free. :-)
我花了几天时间整理出所有陈旧过时的建议,这些建议都是免费的。:-)
回答by Dev Raj
Looks like it is not supported yet by geckodriver/Marionette.
看起来 geckodriver/Marionette 尚不支持它。
You can check below bugs for more information:-
您可以查看以下错误以获取更多信息:-
https://github.com/mozilla/geckodriver/issues/93
https://github.com/mozilla/geckodriver/issues/93
回答by Pratik Patel
If you want to run the tests on Firefox with Selenium 3.0 set the Firefox driver capability “marionette” to false.
如果您想在带有 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();
}