Git Product home page Git Product logo

cucumber-screenshot's Introduction

Cucumber Screenshot

Cucumber Screenshot makes it easy to capture HTML snapshots and PNG screenshots of the pages generated by your Rails application as it runs your Cucumber/Webrat features.

It uses WebKit to generate the PNG screenshots and so they are only available for OS X.

If you want to take bitmap screenshots on any other platform then take a look at this example from Cucumber.

Requirements

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

Install

To install the latest release as a gem

gem install cucumber-screenshot

If you want to take PNG screenshots you will also need to install snapurl

gem install snapurl --version=0.3.0

Set up your rails application

Create a cucumber_screenshot_env.rb file in the ./features/support/ directory in your Rails project and put the following in it.

begin
  require 'cucumber_screenshot'
  World(CucumberScreenshot::World)

  After do |scenario|
    if scenario.failed?
      screenshot
    end
  end

  AfterStep('@screenshot') do |scenario|
    if screenshot_due?
      screenshot
    end
  end
rescue Exception => e
  puts "Snapshots not available for this environment. Try installing
    cucumber-screenshot with\n\n  gem install cucumber-screenshot\n"
end

By default cucumber screenshot will do it’s best to fix up references to your public assets (images, css, js, etc.) in the HTML for your screenshots to point at the public folder on your file system.

However you may find that rendering is improved if you configure it to reference these via HTTP. Say you have a webserver running on localhost:3000 that will serve the public files then add a cucumber_screenshot.yml file containing the following to your application’s ./config/ directory

base_url: http://localhost:3000

Use

Once you have set up your rails application then simply use the ‘rake cucumber’ and ‘rake cucumber:wip’ tasks as per usual.

Screenshots will be captured for every step failure and for every step in scenarios tagged @screenshot. The PNG screenshots and HTML snapshots will be saved to a the ./features/screenshots/ and ./features/screenshots/html directories respectively in your project.

Capturing a single screenshot

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

Then "screenshot" do
  screenshot
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 generated.

TODO

  • Offer option to clean out existing snapshots before each run

  • Add a Rails generator to add the env and step code to a project

License

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

cucumber-screenshot's People

Contributors

mocoso avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

brimil01

cucumber-screenshot's Issues

Please, fix/add in README

< gem install snapurl --version=0.3.0

gem install snapurl --version=0.0.3

http://rubygems.org/gems/snapurl

And write in README the next: (requirements of snapurl)

  • OS X only.
  • RubyCocoa (Leopard and Snow Leopard will already have this installed)
  • Ruby 1.8.7 (Ruby 1.9.x wont play with RubyCocoa)

I have loss my time because i have not OS X Linux :-(

In other way: cucumber-screenshot is very interesant!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.