Selenium firefox - WebDriverException: Reached error page: about:certerror

£可爱£侵袭症+ 提交于 2019-12-22 10:59:21

问题


Meta :-

  • Firefox v51.0.1 (32-bit)
  • Windows 10
  • Selenium 3.0.1
  • Geckodriver Win32 v0.13.0
  • Java v1.8.0_71

Steps to reproduce :-

WebDriver driver = new FirefoxDriver();
driver.get("untrusted/self-signed URL")

Stacktrace :-

org.openqa.selenium.WebDriverException: Reached error page: about:certerror?e=nssBadCert&u=xxxxxxxx&c=UTF-8&f=regular&d=xxxxxx%20uses%20an%20invalid%20security%20certificate.%0A%0AThe%20certificate%20is%20not%20trusted%20because%20it%20is%20self-signed.%0AThe%20certificate%20is%20not%20valid%20for%20the%20name%20xxxxxx%0A%0AError%20code%3A%20%3Ca%20id%3D%22errorCode%22%20title%3D%22SEC_ERROR_UNKNOWN_ISSUER%22%3ESEC_ERROR_UNKNOWN_ISSUER%3C/a%3E%0A Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700' System info: host: 'Saurabh-PC', ip: '192.168.3.8', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_71' Driver info: org.openqa.selenium.firefox.FirefoxDriver

Screenshot :-

I have also tried using FirefoxProfile as :-

DesiredCapabilities dc = DesiredCapabilities.firefox();
dc.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);

FirefoxProfile profile = new FirefoxProfile();
profile.setAcceptUntrustedCertificates(true);

dc.setCapability(FirefoxDriver.PROFILE, profile);

WebDriver driver =  new FirefoxDriver(dc);
driver.get("untrusted/self-signed URL");

But issue is the same as above.

Reference Link which have tried :-

  • How to disable Firefox's untrusted connection warning using Selenium?
  • https://groups.google.com/forum/?fromgroups#!topic/webdriver/frWtNrEwNPk
  • Handling UntrustedSSLcertificates using WebDriver

According to this bug Support for untrusted/self-signed certificates has been added via bug 1103196 and will be available starting with Firefox 52.

But I could not find any solution for Firefox v51.0.1 (32-bit).

Is there any way to solve this issue using Firefox v51.0.1 (32-bit)?


回答1:


As in this bug mentioned Support for untrusted/self-signed certificates will be available starting with Firefox 52, we need to wait until Firefox 52 is not released.


Solution :- For now, as alternate solution we need to use existing Firefox profile where the certificate for untrusted/self-signed URL is already added into Firefox's exception list.

How to create custom Firefox profile for selenium?

  • Need to follow this link to create manually custom Firefox profile
  • Add manually certificate for untrusted/self-signed URL into Firefox's exception list

  • Launch Firefox using existing profile as :-

    System.setProperty("webdriver.gecko.driver", "path/to/geckodriver")
    
    ProfilesIni profile = new ProfilesIni();
    FirefoxProfile myprofile = profile.getProfile("created Profile Name");
    
    WebDriver driver = new FirefoxDriver(myprofile);
    driver.get("untrusted/self-signed URL");
    


来源:https://stackoverflow.com/questions/42359835/selenium-firefox-webdriverexception-reached-error-page-aboutcerterror

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!