如何与Capybara启用证书信任?

时间:2012-09-28 23:13:52

标签: ruby capybara

我有以下代码:

Capybara.register_driver :selenium do |app|
  driver = Capybara::Selenium::Driver.new(app, browser: :firefox, profile: "selenium")
  driver.browser.manage.window.resize_to(600,800)
  driver
end

在运行测试期间,有一个带证书的弹出窗口,所以每次我都要按它。

如何自动执行此操作,或将Capybara firefox配置文件配置为自动接受证书?

1 个答案:

答案 0 :(得分:1)

根据记录here,您需要在assume_untrusted_certificate_issuer上将false设置为Firefox::Profile。例如:

Capybara.register_driver :selenium do |app|
  profile = Selenium::WebDriver::Firefox::Profile.new
  profile.assume_untrusted_certificate_issuer = false # <= this should work
  driver = Capybara::Selenium::Driver.new(app, :profile => profile)
  driver.browser.manage.window.resize_to(600,800)
  driver
end

如果您想了解firefox驱动程序的详细信息,请参阅http://code.google.com/p/selenium/wiki/UntrustedSSLCertificates