First try at webapp integration testing with capybara on debian

Capybara looks like a promising tecnology for integration testing of web applications, so we decided to give it a try on debian jessie workstation.

There are some howtos around based on rails or other ruby-specific stuff, but what is required for a first try (see KISS phylosophy = Keep it Simple Stupid) is to run one test interactively with irb (the Interactive Ruby Shell).
There is a ruby-capybara debian package, but it only comes with rack_test driver. It looks tricky to configure with other drivers, as per Debian Bug report #705739; also its popcon data with 9 submitters suggest it may not trendy.

The RubyGems package manager seems to do the job better, so let’s remove the ruby-capybara package, install ruby-dev (for the header files to compile ruby extensions)  and launch gem for capybara and the selenium webdriver:

sudo apt-get remove ruby-capybara
sudo apt-get install ruby-dev
sudo gem install capybara
sudo gem install selenium-webdriver

Now start irb and try this:

require 'capybara/dsl'
Capybara.default_driver = :selenium
Capybara.app_host = 'http://bing.com'
Capybara.default_wait_time = 15
Capybara.visit '/'
Capybara.fill_in 'sb_form_q', :with => 'simevo'
Capybara.find('#sb_form_go').click

Mandatory screenshot:

capybara

avatar

About paolog

homo technologicus cynicus
This entry was posted in Howtos, UI, Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *