Adding security exceptions in Firefox

老子叫甜甜 提交于 2020-01-02 10:35:42

问题


I have a script running watir-webdriver(using Firefox 4.0) that needs to access a web page that Firefox thinks has an invalid certificate.

The problem is that after I accept the certificate, Firefox just goes right back to the same page as if I never accepted it.

This only occurs if Firefox was started from watir-webdriver. If I start it manually, it will properly accept the security exception.


回答1:


The Firefox driver creates a new anonymous profile for each instance, so that it's working in your default profile but not with WebDriver isn't that suprising.

WebDriver is usually pretty good at dealing with certificate issues, but there is an edge case: you're serving a valid certificate that doesn't match the host name it's served from (e.g. production certificates in a test environment). If that's the case, you'll want to set a flag in the Firefox profile:

profile = Selenium::WebDriver::Firefox::Profile.new
profile.assume_untrusted_certificate_issuer = false

browser = Watir::Browser.new(:firefox, :profile => profile)

If that doesn't help, you can also just use your default profile as a model:

browser = Watir::Browser.new(:firefox, :profile => "default")



回答2:


Have your tried going to Tools->Options->-Advanced->Encryption Tab Then click the Validation button and uncheck use the Online Certificate Status Protocol (OCSP) ...

You can disable this programatically with the Ruby bindings for Selenium e.g.

require 'selenium-webdriver'
require 'watir-webdriver'
profile = Selenium::WebDriver::Firefox::Profile.new
profile["security.OCSP.enabled"] = 0
driver = Selenium::WebDriver.for :firefox, :profile => profile
browser = Watir::Browser.new(driver)


来源:https://stackoverflow.com/questions/5589139/adding-security-exceptions-in-firefox

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