I've got some problems running capybara-webkit with the Headless gem, Xvfb and our ci server. We use this setup for automatic integration testing and javascript testing of our Ruby on Rails 3.2 app. During the tests it complains that
webkit_server: cannot connect to X server
But when I ps aux | grep Xvfb
deploy 1602 0.0 0.1 61696 1912 pts/2 S+ Jul10 0:00 /usr/bin/Xvfb :99 -screen 0 1280x1024x24 -ac
I see the Xvfb running. If I run the tests with --trace
it also only shows the error log above and I can't debug the error.
Any ideas how I could get some more information, or even a solution?
I was trying to get the capybara-webkit gem working with capybara and ended up using xvfb-run
in the CI job for my tests.
xvfb-run bundle exec cucumber ...
What is the command your CI job is executing?
We ran into the same issue... Turns out that in our spec_helper.rb we were missing the headless start command (below).
Here's our rspec config:
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/rspec'
require 'capybara/webkit'
require 'headless'
Capybara.register_driver :webkit do |app|
Capybara::Driver::Webkit.new(app, :ignore_ssl_errors => true)
end
Capybara.javascript_driver = :webkit
# don't run on the local machine (since we don't have xvfb running locally)
if Rails.env.production?
headless = Headless.new
headless.start
end
If you're using Travis CI, you might get some mileage from this configuration setting:
before_install:
- "echo 'gem: --no-document' > ~/.gemrc"
- "echo '--colour' > ~/.rspec"
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
Install xvfb
sudo apt-get install xvfb
Then execute your command using xvfb
xvfb-run rspec
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With