Firefox 中使用 WebDriver 和 C# 的不受信任的 SSL 证书 [英] Untrusted SSL Certificates in Firefox Using WebDriver and C#
问题描述
更新:我升级到 Selenium 2.37 但仍然有同样的问题!!
UPDATE: i upgrade to Selenium 2.37 but still having the same problem!!
最新定义首选项后仍然不起作用(见下文)
LATEST still does not work after defining the pref (see below)
//some more prefs:
profile.SetPreference("network.http.phishy-userpass-length", 255);
profile.SetPreference("network.automatic-ntlm-auth.trusted-uris", _url);
profile.SetPreference("webdriver_assume_untrusted_issuer", true);
profile.SetPreference("webdriver_accept_untrusted_certs", true);
profile.SetPreference("trustAllSSLCertificates", true);
我使用的是 FF 25.0.1网络驱动版本:2.31
I'm using FF 25.0.1 Webdriver version: 2.31
我以前从来没有遇到过这个问题,但是当我开始运行我的自动化测试用例时才开始,所以发生的事情是我收到 SSL 认证错误,即使我已经接受并添加为异常,但我仍然收到错误并且因此我的测试用例失败了...
I never had this problem before but just started when i start running my automated test cases so what is happening is that i am getting SSL certification error and even though i have accepted and add as an exception but i still getting the error and hence my test case is failing...
这是我在构建 ff webdriver 时添加的内容...
here is what i have added when i'm building ff webdriver...
FirefoxProfile profile = new FirefoxProfile();
profile.SetPreference("network.http.phishy-userpass-length", 255);
profile.SetPreference("network.automatic-ntlm-auth.trusted-uris", _url);
profile.SetPreference("webdriver_assume_untrusted_issuer", false);
drv = new FirefoxDriver(profile);
推荐答案
我已经尝试了@Akabar 在评论中写的方法,我可以分享更多关于我如何解决这个问题的细节:您可以在此处查看以供参考:Selenium Webdriver: SurpressingFirefox 中的不可信连接消息
I've tried the way @Akabar wrote above in the comment and I can share more detail s about how I fix this issue: You can check here for your reference: Selenium Webdriver: Surpressing untrusted connection message in firefox
步骤是:
步骤 1 - 手动打开您的 FF 并手动接受自签名证书(我的意思是接受sec_error_unknown_issuer"安全例外)
Step 1 - Open your FF manually and accept the self-signed certificate manually (I mean accept "sec_error_unknown_issuer" security exception)
第 2 步 - 找到您的 FF 的配置文件目录并复制您的配置文件目录的路径,例如(MAC env):/Users/UserABC/Library/Application Support/Firefox/Profiles/vndms5adearwtry.default"
Step 2 - Locate your FF's profile directory and copy the path of the your profile directory, ex(MAC env): "/Users/UserABC/Library/Application Support/Firefox/Profiles/vndms5adearwtry.default"
第 3 步 - 在您的 selenium 代码(java 版本)中,使用以下方式初始化 FirefoxDriver:
Step 3 - In your selenium code(java version), use the following way to init the FirefoxDriver:
FirefoxProfile firefoxProfile = new FirefoxProfile(new File("/Users/UserABC/Library/Application Support/Firefox/Profiles/vndms5adearwtry.default"));
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability(FirefoxDriver.PROFILE, firefoxProfile);
FirefoxDriver driver = new FirefoxDriver(capabilities);
希望有帮助.
这篇关于Firefox 中使用 WebDriver 和 C# 的不受信任的 SSL 证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!