TestingBot Blog

TestingBot provides a cloud of browsers and devices, ready to run your Automated, Live and Visual tests.

< Back to Blog Overview

Ruby testing with Cucumber and Capybara

2012-02-19

In this post you'll find a small tutorial on how to use Cucumber and Capybara to run Selenium tests on our Selenium grid.


Cucumber is Aslak Hellesøy’s rewrite of RSpec’s "Story runner". It uses plain text DSL (Gherkin), which we mentioned in a previous post (Behat and Mink), meaning you can write tests as stories.


Capybara fits nicely together with Cucumber when writing web application tests using Selenium.


To begin, let's create a directory called features which will hold all the files Cucumber requires: $ mkdir features


Now we'll add a configuration file so Cucumber knows what to do:


This file tells Cucumber we will run the Selenium test on TestingBot.com's grid.


Now let's create a story (feature): $ vim features/youtube.feature


If you would now run "cucumber", you would see the following:


You'll know need to specify the step definitions from your feature, create a file youtube_steps.rb:

If you run cucumber again, your test should succeed and a video + screenshots should be available in our member area.

We hope this simple tutorial demonstrates how easy it is to start testing your website in minutes. You can find these demo files in our GitHub repository.

< Back to Blog Overview

Sign up for a Free Trial

Start testing your apps with TestingBot.

No credit card required.