问题
In my spec_helper file I have:
Capybara.javascript_driver = :webkit
capybara_webkit now has a ignore_ssl_errors
option that I want to use. How do I specify that in my spec_helper?
回答1:
Here's how to register the :webkit driver with the :ignore_ssl_errors option.
Capybara.register_driver :webkit do |app|
Capybara::Driver::Webkit.new(app, :ignore_ssl_errors => true)
end
回答2:
As of writing (capybara-webkit 1.7.1), the configuration seems to have been simplified:
Capybara::Webkit.configure do |config|
config.ignore_ssl_errors
end
(source)
回答3:
Somehow the above register_driver
examples don't work with Capybara 1.1.4. The example below is taken from the capybara browser_spec.rb.
Capybara.register_driver :webkit_ignore_ssl do |app|
browser = Capybara::Webkit::Browser.new(Capybara::Webkit::Connection.new).tap do |browser|
browser.ignore_ssl_errors
end
Capybara::Webkit::Driver.new(app, :browser => browser)
end
Capybara.javascript_driver = :webkit_ignore_ssl
回答4:
As @hjblok says, the interface has changed in recent versions of capybara-webkit. You can simplify the solution slightly:
Capybara.register_driver :webkit_ignore_ssl do |app|
Capybara::Webkit::Driver.new(app).tap {|d| d.browser.ignore_ssl_errors }
end
Capybara.javascript_driver = :webkit_ignore_ssl
回答5:
When createing a new webkit Object you can use this to ignore the ssl errors
Capybara::Driver::Webkit.new({ :ignore_ssl_errors => true})
来源:https://stackoverflow.com/questions/7855269/how-to-set-the-ignore-ssl-errors-option-for-capybara-webkit-in-spec-helper-rb