我有一个运行watir-webdriver(使用Firefox 4.0)的脚本,它需要访问Firefox认为具有无效证书的网页。
问题是,在我接受证书后,Firefox只是直接返回到同一页面,就好像我从未接受过它一样。
只有当Firefox从watir-webdriver启动时,才会发生这种情况。如果我手动启动它,它将正确地接受安全异常。
发布于 2011-04-08 08:16:15
火狐驱动为每个实例创建一个新的匿名配置文件,所以它可以在你的默认配置文件中工作,但不能在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-08 03:03:36
尝试进入Tools->Options->-Advanced->Encryption Tab,然后单击Validation按钮并取消选中use the Online Certificate Status Protocol (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)
https://stackoverflow.com/questions/5589139
复制相似问题