Capybara Webkit Capybara::Webkit::ConnectionError failed to start - qtwebkit

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

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.

Related

Locking the version of PhantomJS that Poltergeist uses

I have a Ruby on Rails app that runs feature tests using Capybara, Poltergeist and PhantomJS.
Version 2.0.0 of PhantomJS has a rather significant bug that breaks a lot of tests (https://github.com/ariya/phantomjs/issues/12506) so I'd like to force the app to use a different version of PhantomJS when running the tests.
Is this possible from within Poltergeist's configuration, to raise an error or a warning if this buggy version is used, or is my best bet simply putting a note in the app's readme saying 'don't use version 2.0.0 due to this bug'?
at the moment my Capybara/Poltergeist configuration is very basic:
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, :timeout => 90)
end
As #pguardiario commented, you can just do something like
if `phantomjs -v`.start_with? '2'
#output whatever kind of warning you want
end
however the Poltergeist master branch has a fix for that particular issue so you could just try using that instead

rvm using /after_cd_bunlder vs --binstubs. How are these different?

How are the outcome of these two methods different? Why use one over the other? I believe they both end up enabling you to issue 'rake' or 'rspec' without the preceeding 'bundle exec". My guess - with method 1 you only have to do this once, and then on ALL new rails project for the rvm ruby version will automatically have the desired feature ( as explained above)?
Method 1:
rvm get head && rvm reload
chmod +x $rvm_path/hooks/after_cd_bundler
bundle install --binstubs
OR
Method 2:
bundle install --binstubs
If found this documentation, but it did not help me understand which method to use. I looked on http://rvm.io and found intergration/bundler and /workflow/hooks.
The is code for after_cd_bundler (but I cannot post anymore links due to stackoverflow.com limitations on me)
This are not two different methods, this is one method and it is described in more detail here: http://robots.thoughtbot.com/post/15346721484/use-bundlers-binstubs
If you are using RVM then you do not need any of this, using --binstubs requires adding to PATH - which is big security risk if used from project directory, RVM comes with rubygems-bundler gem preinstalled which does the automatic loading of bundler (no need for bundle exec), you can find more details about the gem here: https://github.com/mpapis/rubygems-bundler#readme
I am author of rubygems-bundler and maintainer of RVM.

Capybara element not found just on Travis

I'm trying to put the free software where I'm one of the collaborators to run the acceptance tests on Travis. Everything went very well except for the acceptance tests with selenium.
And this is a difficult issue because the software uses only the gem versions avaiable on Debian 6. So, everything is really outdated.
Being more specific, just the steps where I'm looking for some text on the screen, with the step:
page.should have_content(text)
I've already tried to:
to add some waiting since it could be looking for the element before it was rendered;
update the xpath;
remove the webrat, because I've read that it could be conclicting with capybara;
run the tests locally with xvfb;
create a VM with Ubuntu Server 12.04 32 bits (Travis version), install everything and run the tests on xvfb;
update Capybara from 1.1.1 to 1.1.4.
But the problem persists:
# features/step_definitions/web_steps.rb:107
Unable to find xpath "/html" (Capybara::ElementNotFound)
(eval):2:in `send'
(eval):2:in `text'
./features/step_definitions/web_steps.rb:110
./features/step_definitions/web_steps.rb:14:in `with_scope'
./features/step_definitions/web_steps.rb:108:in `/^(?:|I )should see "([^"]*)"(?: within "([^"]*)")?$/'
plugins/mezuro/features/repository.feature:101:in `And I should see "My Name"'
Here is the link for the build:
https://travis-ci.org/rafamanzo/mezuro-travis/builds/6231714
Anyone have any idea? I'm afraid that it is related with the gem versions and I'll not be able to fix it by any means.
Here are links for what I was able to find about it on Google:
https://groups.google.com/forum/#!msg/ruby-capybara/PDr7sZ124Vw/qLXqHXs0XdMJ
https://github.com/rspec/rspec-rails/issues/406
Thank you very much!

Error while running Metrical

I've a Ruby 1.9.2 and Rails 3.0.9 development environment. When I run the gem "metrical" on my application, I get the following errors:
** Running the specs/tests in the [test] environment
Analyzing: 100% |oooooooooooooooooooooooooooooooooooooooooo| Time: 00:00:00
/Users/tester/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/emitter.rb:17:in `end_document': undefined method `write' for #<Syck::Emitter:0x000001028d2388> (NoMethodError)
Anyone else seen this issue? I'm out of ideas for the error.
I ran into the same problem, seems to be related to YAML parsing with Ruby 1.9.2
I hacked into metric fu and inserted a explicit requirement of the Psych YAML Engine:
metric_fu-2.1.1/lib/metric_fu.rb:
require 'rake'
require 'psych' # <-- added here
require 'yaml'
And now works...
The simplest solution is to set the RUBYOPT environment variable when you run metrical, so instead of metrical you type:
RUBYOPT='-rpsych' metrical
I am doing that and it's all working fine. This blog post figured it out for me: http://excid3.com/blog/undefined-method-write-for-syckemitter/ (possibly a bit simpler than hacking into metric_fu, until they fix this).

Prologue with Ruby on Rails 3

I'm a total newbie to RoR and am trying to get the Prologue gem up and running. I've downloaded the prologue zip file from github.com/quickleft/prologue and am trying to follow the instructions in the associated readme file. I have encountered a number of issues....
Q1: What do I actually do with the extracted zip file? For instance, am I supposed to place the extracted files inside specific rails application directories or what ?
I've been able to install the gem by executing "gem install prologue". However, I cannot create a new application using the "prologue new my_app" command - the following message is displayed at the command prompt when I execute that command:
*C:/Ruby192/lib/ruby/gems/1.9.1/gems/prologue-0.3.10/lib/prologue/cli.rb:58:in ``
': No such file or directory - git config --global user.name (Errno::ENOENT)
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/prologue-0.3.10/lib/prologue/cli.rb:58:in `git_user_name'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/prologue-0.3.10/lib/prologue/cli.rb:33:in new'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/task.rb:22 :inrun'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:118:in invoke_task'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor.rb:263:in dispatch'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/base.rb:38
9:instart'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/prologue-0.3.10/bin/prologue:4: in <top (required)>'
from C:/Ruby192/bin/prologue:19:inload'
from C:/Ruby192/bin/prologue:19:in `'*
Q2: Does anyone have any advice on how to overcome this problem?
Q3: Also, when attempting to get prologue up and running is it possible to do this without integrating it into an existing rails application? If so, how?
(I have ruby 1.9.2 and rails 3.0.0 installed on a Windows Vista machine)
Advice/feedback on the above issues would be greatly welcome!
It seems that Prologue needs 'thor', another gem. You can install all dependencies with the command 'bundle install'.
You can integrate Prologue in a new Rails app, but you definitely need some (existing or new) Rails app to run it.