java - Selenium 火狐 - WebDriverException : Reached error page: about:certerror

标签 java selenium firefox selenium-firefoxdriver geckodriver

元:-

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

重现步骤:-

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

堆栈跟踪:-

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

截图:-

enter image description here

我也尝试过使用 FirefoxProfile 作为 :-

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

但问题同上。

已尝试的引用链接:-


根据 this bug通过 bug 1103196 添加了对不受信任/自签名证书的支持并将从 Firefox 52 开始可用。

但我找不到任何适用于 Firefox v51.0.1(32 位) 的解决方案。

有没有办法使用 Firefox v51.0.1(32 位) 解决这个问题?

最佳答案

this bug提到对不受信任/自签名证书的支持将从 Firefox 52 开始可用,我们需要等到 Firefox 52 未发布。


解决方案:- 目前,作为替代解决方案,我们需要使用现有的 Firefox 配置文件,其中 untrusted/self-signed URL 的证书已添加到 Firefox 的异常(exception)列表.

How to create custom Firefox profile for selenium?

enter image description here

  • 使用现有配置文件启动 Firefox :-

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

关于java - Selenium 火狐 - WebDriverException : Reached error page: about:certerror,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42359835/

相关文章:

java - 在 Oracle ucp 中找不到 oracle.ucp.jdbc.PoolDataSourceFactory

java - 如何强制类的调用者捕获异常?

java - Google Webmaster Tools API 能否用于自动修复 URL Page Not Found 错误?

html - Firefox:宽度百分比问题

javascript - 如果我使用 gzipped JavaScript 文件,我在 Chrome 和 Firefox 中都会遇到非法字符/标记错误

java - 在java中限制应用程序的多个实例

java - 如何获取员工 ID 并将其放入其他元素中

c# - Selenium - 强制点击不可见元素

node.js - 为什么我会得到之前的选项卡 url?

python - 屏幕抓取图像(即 Firefox 页面信息/谷歌图像)