【问题标题】:Invalid Security Cert error when using Python Selenium WebDriver with Firefox GeckoDriver将 Python Selenium WebDriver 与 Firefox GeckoDriver 一起使用时出现无效的安全证书错误
【发布时间】:2017-07-23 08:30:47
【问题描述】:

我正在更新我们用于内部 Selenium 测试的 Firefox 版本。作为其中的一部分,我知道我需要使用 GeckoDriver,就像我们需要使用 ChromeDriver for Chrome。它似乎已全部投入,但被测软件使用自签名 ssl 证书,在继续之前会给您“不受信任”的证书警告。为了解决这个问题,我有以下代码:

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

profile = webdriver.FirefoxProfile()
profile.accept_untrusted_certs = True
capabilities = DesiredCapabilities.FIREFOX
capabilities['acceptSslCerts'] = True
firefox_log = "<path to firefox log>"

DRIVER = webdriver.Firefox(firefox_profile=profile, executable_path=<path to gecko driver exe>, capabilities=capabilities, log_path=firefox_log)

但是,当测试运行时,它会运行/打开 Firefox,但它会立即出错并显示以下错误:

WebDriverException: Message: Reached error page: about:certerror?e=nssBadCert&u=https%3A//10.10.10.10/&c=UTF-8&f=regular&d=10.10.10.10%20uses%20an%20invalid%20security%20certificate.%0A%0AThe%20certificate%20is%20not%20trusted%20because%20it%20is%20self-signed.%0AThe%20certificate%20is%20only%20valid%20for%20%3Ca%20id%3D%22cert_domain_link%22%20title%3D%22amnesiac%22%3Eamnesiac%3C/a%3E%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

我知道该区域存在错误,但我认为它已修复。我错过了什么吗?

版本信息:

  • 火狐版本:51.0.1
  • GeckoDriver 版本:0.14.0
  • 硒版本:3.0.2

【问题讨论】:

  • 我也尝试过使用“acceptInsecureCerts”而不是“acceptSslCerts”,我得到了相同的结果。

标签: python selenium firefox ssl geckodriver


【解决方案1】:

我正面临这个问题,试图让这个功能在 .NET 中为我工作。但我确实注意到您使用的是 Firefox 51.0.1。虽然自(我相信)GeckoDriver 0.11.0 以来对此的错误修复一直存在,但它依赖于 Firefox 中的错误修复,根据original bug,它是VERIFIED FIXED in Firefox 52。所以我会尝试更新 Firefox,因为 52 成为 2016 年 3 月 7 日的稳定版本。希望有帮助。

【讨论】:

  • 关于你提到的 Joshua,我也在使用 .NET。我昨天将 Firefox 更新到 52 版,突然我无法通过 IIS Express 访问 localhost 中的 SSL 网站。我尝试导出 IIS Express 证书并将其作为 CA 导入 Firefox,但它不允许这样做。我已经验证,如果我回到 Firefox 51,该网站会再次运行。你有同样的问题吗?
  • 对于不安全的站点,我没有尝试过配置文件解决方法。如果我不知道如何在驱动程序初始化期间设置这些功能,我可能不得不走这条路。目前我的测试节点都运行 Firefox 46,所以我不必使用 Marionette 驱动程序,但这正日益成为一个更大的问题。
  • 我升级到了 52。然后我确保按照开发者博客 (hskupin.info/2017/01/23/…) 使用 Capabilities 路由触发修复。我现在看到了别的东西。现在我收到以下错误:WebDriverException: Message: Message: Can't load the profile. Profile Dir: /var/folders/v_/jr5_8tpj62z0fx14nsbyb_fm0000gp/T/tmpV0GVtz If you specified a log_file in the FirefoxBinary constructor, check it for details. 这似乎是这个错误:github.com/SeleniumHQ/selenium/issues/2739
  • Selenium 和 GeckoDriver 的较新版本现已推出......我会尝试这些。
猜你喜欢
  • 2018-03-31
  • 2017-04-04
  • 1970-01-01
  • 2017-07-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-09-17
相关资源
最近更新 更多