Untrusted SSL Certificates in Firefox Using WebDri

2019-01-27 04:21发布

UPDATE: i upgrade to Selenium 2.37 but still having the same problem!!

LATEST EDIT: 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);

I'm using FF 25.0.1 Webdriver version: 2.31

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...

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);

screen shot.

4条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-01-27 04:42

Can you set this preference as true and try -- webdriver_accept_untrusted_certs

查看更多
家丑人穷心不美
3楼-- · 2019-01-27 04:49

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

The steps are:

Step 1 - Open your FF manually and accept the self-signed certificate manually (I mean accept "sec_error_unknown_issuer" security exception)

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"

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);

Hope it helps.

查看更多
女痞
4楼-- · 2019-01-27 04:50

Any reason why you are not running selenium with -trustAllSSLCertificates -switch?

查看更多
再贱就再见
5楼-- · 2019-01-27 04:58

I'm having this too, but with Java API. I just discovered this issue on Selenium 2.35, hoping a resolution upgrading in 2.37... The problem is there with both firefox 24.0.1 and 25.0. It works with ChromeDriver

For now, I found only one website where the problem occurred (https://twitter.com) IS the website your testing is public ? I would appreciate to reproduce on another place.

查看更多
登录 后发表回答