Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cant get capybara-webkit to work

I am using capybara to do integration testing on my rails 3 app.

When i add :js => true to a scenario my tests work with selenium but when i change to use the webkit driver for js i get errors for each like this :

Capybara::Driver::Webkit::WebkitInvalidResponseError: Unable to load URL: http://www.example.dev:7171/user_sessions

My add is a multi domain app so in my spec_helper i set port : Capybara.server_port = 7171

And in a background block i set the app_host like this : Capybara.app_host = "http://#{subdomain}.example.dev:7171"

If i then add this to my spec_helper rspec.configure block i then get the errors above :

config.before(:each) do
   DatabaseCleaner.start
   Capybara.run_server = false
   Capybara.javascript_driver = :webkit
   Capybara.default_selector = :css
   Capybara.server_port = 7171 
end

Can anyone help with this? I am also using spork for auto testing.

like image 578
Rick Moss Avatar asked Sep 14 '11 10:09

Rick Moss


2 Answers

There is an open issue for an issue that seems exactly like this on github => https://github.com/thoughtbot/capybara-webkit/issues/87

They have some workaround suggestions in there, see if that doesn't help you out. Good luck!

like image 119
StevenMcD Avatar answered Sep 23 '22 07:09

StevenMcD


Is your application redirecting to a secure (https://) url?

If so you'll need to redeclare the :webkit driver for Capybara with the :ignore_ssl_errors option set to true:

Capybara.register_driver :webkit do |app|
  Capybara::Driver::Webkit.new(app, :ignore_ssl_errors => true)
end
like image 39
Louis Simoneau Avatar answered Sep 24 '22 07:09

Louis Simoneau