【问题标题】:How do I force Firefox Selenium Webdriver(Python) to accept any SSL certificates如何强制 Firefox Selenium Webdriver(Python) 接受任何 SSL 证书
【发布时间】:2016-10-18 11:39:39
【问题描述】:

我正在尝试修复内部应用程序的测试,目前我并不关心安全性(我只想让它工作)。

它给了我 SSL 警告,破坏了测试。具体来说,您的连接不安全/SEC​​_ERROR_UNKOWN_ISSUER。

我已经尝试过设置capabilities['acceptSslCerts'] = True

profile = webdriver.FirefoxProfile()
profile.accept_untrusted_certs = True

两者都不起作用。驱动程序在构建后列出的功能将 acceptSslCerts 设置为 false。

注意我使用的是 Python 和 Firefox 47。

我还改用了新的 marionette Firefox Webdriver,因为常规的在启动时崩溃了。

【问题讨论】:

  • 也试试 Chromedriver。因为它比 Firefox 和 Selenium 更稳定。

标签: selenium firefox ssl selenium-webdriver selenium-firefoxdriver


【解决方案1】:

Firefox 自签名证书错误现已修复:accept ssl cert with marionette firefox webdrive python splinter

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

caps = DesiredCapabilities.FIREFOX.copy()
caps['acceptInsecureCerts'] = True
ff_binary = FirefoxBinary("path to the Nightly binary")

driver = webdriver.Firefox(firefox_binary=ff_binary, capabilities=caps)
driver.get("https://expired.badssl.com")

【讨论】:

  • 谢谢,但我现在坚持使用旧驱动程序
  • 在最新的 Firefox + driver + selenium 上运行之前,我测试的最后一个配置是:Firefox v46 geckodriver v0.8.0 selenium v​​2.53.6 希望对你有帮助
【解决方案2】:

问题在于 Firefox 版本 47(请参阅 https://github.com/SeleniumHQ/selenium/issues/2110)。

所以你最好去等待修复 Firefox/Selenium,或者你降级Firefox 46

【讨论】:

  • 不兼容的消息总是有点不同和奇怪。所以,如果你真的需要,不妨试试。
  • 问题是信任 ssl 不受信任的证书尚不可用 w/ marionette (bugzilla.mozilla.org/show_bug.cgi?id=1103196) 切换回经典驱动程序和 firefox 45
  • 很高兴知道。我同时切换到 Chrome,因为它不像 Firefox 那样容易出错。可悲的是,作为 Firefox 的忠实粉丝。 =/
猜你喜欢
  • 2016-10-18
  • 1970-01-01
  • 2012-06-29
  • 2016-06-05
  • 2021-05-12
  • 2018-04-30
  • 2013-12-06
  • 2019-12-03
  • 1970-01-01
相关资源
最近更新 更多