15

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.

lucapette
  • 20,564
  • 6
  • 65
  • 59
Rick Moss
  • 926
  • 1
  • 17
  • 34

3 Answers3

1

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!

StevenMcD
  • 17,262
  • 11
  • 42
  • 54
1

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
Louis Simoneau
  • 1,781
  • 14
  • 18
0

Just wanted to say that we just had the same error on our Ubuntu CI server. It's an LTS build and so was running an older libqt (v4.6.2) - upgrading (using the tarball) to 4.7.4 fixed the problem. Probably won't help your situation, but something worth checking.

smathy
  • 26,283
  • 5
  • 48
  • 68
  • 1
    Thanks for this hint, I had the problem above and this made me realise that between installing capybara-webkit and then using it, I'd updated QT to 4.8 on my machine and I needed to rebuild the gem :) Saved me hours of frustration – workmad3 Mar 14 '12 at 14:59
  • Thanks for the comment (I recognize you from #rubyonrails :) - I was hoping someone would see it and it'd be just that little hint they needed. – smathy Jun 15 '12 at 20:56
  • What version of Ubuntu were you running, @smathy? – thekingoftruth Dec 19 '12 at 00:10
  • We were running 10.04 LTS on that server. – smathy Dec 20 '12 at 21:36