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

我的梦境 提交于 2019-12-05 06:35:26

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.

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.

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