1

我需要使用 selenium 自动选择我自己的证书。经过一些研究,我发现最好的方法是创建一个 Firefox 配置文件,添加证书并在 Selenium Webdriver 中“导入”我的配置文件。

我想做什么?

  • 在 Firefox 上创建个人资料用户
  • 添加我的证书
  • Selenium 导入此配置文件

会发生什么?

# Open My Profile
profile = webdriver.FirefoxProfile('/home/USERNAME/.mozilla/firefox/ri4nkdyn.default')

# Preferences that I tested
profile.set_preference("security.default_personal_cert", "Select Automatically")
profile.set_preference("security.osclientcerts.autoload", True)
profile.set_preference("security.disable_button.openCertManager", True)
profile.set_preference("security.enterprise_roots.enabled", True)
profile.set_preference("accept_untrusted_certs", True)
profile.set_preference("assume_untrusted_cert_issuer", True)

# Firefox Binary
ff_binary = FirefoxBinary('/usr/bin/firefox')

# Desired Capabilities that I tested
desired_capabilities = DesiredCapabilities.FIREFOX.copy()
desired_capabilities["acceptInsecureCerts"] = True
desired_capabilities['acceptSslCerts'] = True


# Create the Webdriver Firefox
driver = webdriver.Firefox(
    firefox_binary=ff_binary,
    firefox_profile=profile,
    desired_capabilities=desired_capabilities
)

我该如何解决这个问题?怎么了?

4

1 回答 1

0

Edit your firefox profile by choosing cert. or type "about:config" in the browser address bar. Verify Preference Name "security.default_personal_cert" is set to "Select Automatically" and after that use that profile for your firefox tests.

于 2021-01-20T13:40:42.720 回答