在Firefox中添加安全例外 [英] Adding security exceptions in Firefox

查看:1196
本文介绍了在Firefox中添加安全例外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

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

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

仅当从watir-webdriver启动Firefox时,才会发生这种情况.如果我手动启动它,它将正确接受安全例外.

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

推荐答案

Firefox驱动程序会为每个实例创建一个新的匿名配置文件,这样它就可以在您的默认配置文件中使用,但不能与WebDriver一起使用.

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通常非常擅长处理证书问题,但是有一个极端的情况:您提供的有效证书与提供该证书的主机名不匹配(例如,测试环境中的生产证书).在这种情况下,您需要在Firefox配置文件中设置一个标志:

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

这篇关于在Firefox中添加安全例外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆