2

我有一个运行 watir-webdriver(使用 Firefox 4.0)的脚本,它需要访问 Firefox 认为具有无效证书的网页。

问题是,在我接受证书后,Firefox 就像我从未接受过一样直接回到同一页面。

这只发生在 Firefox 从 watir-webdriver 启动时。如果我手动启动它,它将正确接受安全异常。

4

2 回答 2

4

Firefox 驱动程序为每个实例创建一个新的匿名配置文件,因此它可以在您的默认配置文件中工作,但不能使用 WebDriver 并不令人惊讶。

WebDriver 通常非常擅长处理证书问题,但有一个极端情况:您提供的有效证书与提供它的主机名不匹配(例如,测试环境中的生产证书)。如果是这种情况,您需要在 Firefox 配置文件中设置一个标志:

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

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

如果这没有帮助,您也可以使用默认配置文件作为模型:

browser = Watir::Browser.new(:firefox, :profile => "default")
于 2011-04-08T08:16:14.590 回答
1

您是否尝试过工具->选项->-高级->加密选项卡然后单击验证按钮并取消选中使用在线证书状态协议(OCSP)...

您可以使用 Selenium 的 Ruby 绑定以编程方式禁用此功能,例如

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)
于 2011-04-08T03:03:35.507 回答