Adding security exceptions in Firefox

原文链接:http://stackoverflow.com/questions/5589139/adding-security-exceptions-in-firefox

Question:

 

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.

 

Answer:

A1: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")

A2: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)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值