Capybara Webkit Capybara::Webkit::ConnectionError failed to start

☆樱花仙子☆ 提交于 2019-12-07 04:29:23

问题


I'm using capybara webkit on Ubuntu (14.04 LTS) and I'm getting the following error when trying to use it:

Capybara::Webkit::ConnectionError: /srv/www/app/shared/bundle/ruby/2.1.0/gems/capybara-webkit-1.3.1/bin/webkit_server failed to start.
from /srv/www/app/shared/bundle/ruby/2.1.0/gems/capybara-webkit-1.3.1/lib/capybara/webkit/connection.rb:75:in `parse_port'
from /srv/www/app/shared/bundle/ruby/2.1.0/gems/capybara-webkit-1.3.1/lib/capybara/webkit/connection.rb:81:in `discover_port'
from /srv/www/app/shared/bundle/ruby/2.1.0/gems/capybara-webkit-1.3.1/lib/capybara/webkit/connection.rb:62:in `start_server'
from /srv/www/app/shared/bundle/ruby/2.1.0/gems/capybara-webkit-1.3.1/lib/capybara/webkit/connection.rb:25:in `initialize'
from /srv/www/app/shared/bundle/ruby/2.1.0/gems/capybara-webkit-1.3.1/lib/capybara/webkit/driver.rb:17:in `new'

I installed QT using:

sudo apt-get install libqt4-dev libqtwebkit-dev libqt5webkit5-dev

Using gem versions: capybara (2.4.4) and capybara-webkit (1.3.1)

The same program works fine on mac (qt installed using homebrew)

Thanks


回答1:


It has been a long time since this question was asked, but I had the same problem even though I used much more ancient versions of anything. It turned out that webkit needs to be able to connect to some X-Server and this is its reaction if it fails. I ended up installing xvfb and using

 xvfb-run --auto-servernum bundle exec rake test

(aliased of course) when running my tests. This is probably less than optimal, but it was good enough for me. Maybe this helps the next person who stumbles across this error.




回答2:


I beat my head against this all morning. Turns out I had omitted this code from rails_helper.rb :

if ENV['HEADLESS']
  require 'headless'
  headless = Headless.new
  headless.start
  at_exit { headless.stop }
end

We use the HEADLESS environment variable to trigger this. Not sure if that's typical or a local convention. Regardless, I needed to add export HEADLESS=1 to .env to fire that off.

I also had to add gem 'headless', '~> 1.0.2' in Gemfile.



来源:https://stackoverflow.com/questions/27148993/capybara-webkit-capybarawebkitconnectionerror-failed-to-start

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!