Cucumber Screenshot

Cucumber Screenshot adds a new output format to Cucumber that captures screenshots of the pages generated by your Rails application as it runs your Cucumber/Webrat features.

It uses WebKit to generate the screenshots and so is only available for OS X.

Requirements

A Rails application with some features written in Cucumber/Webrat.

Install

To install the latest release as a gem

sudo gem install cucumber-screenshot

Use

Add the following line to your ./features/support/env.rb file

require 'cucumber_screenshot'

and then run

cucumber features --format screenshot

from your Rails application’s directory.

This will create a ./features/screenshots directory in your Rails application with subfolders for each scenario. Each subfolder will contain a screenshot of each page generated and the html source of each of those pages.

Capturing a single screenshot

If you want to capture a single screenshot rather than every page then add the following step to one of your Rails application’s step files

sudo gem install webratThen "screenshot" do
  screenshot.should be_true
end

and then add

Then screenshot

to your feature file in the place where you want to capture a screenshot of the page that your application geneerated.

TODO

  • Clean out existing snapshots before each run

  • Add support for tables

License

Copyright © 2009 Joel Chippindale. See MIT-LICENSE.txt in this directory.