Headless Selenium Screenshots with Cucumber 3

Posted by jcnnghm Wed, 30 Dec 2009 11:24:00 GMT

 I was finally able to get Selenium integrated with Webrat and Cucumber on my Linux development server.  I followed this excellent guide to setting up the selenium server to run headless.  This enables me to run my tests without actually seeing the Firefox window.  This does, unfortunately, make debugging a bit more difficult.

Because of that, I created a Cucumber step to save a screenshot of the webpage in the tmp/screenshots folder.  This includes the entire page, not just the viewable portion.  Not only does this simplify debugging, but it also makes it trivially difficult to capture a large number of screenshots from the testing framework to compile visual reports.  I believe that making sure everything looks right is as much a part of testing as making sure it actually works.


Then /^I save a screenshot with filename "([^\"]*)"$/ do |filename|
  selenium.capture_entire_page_screenshot(File.expand_path("tmp/screenshots/#{filename}.png"), "")

Use the following link to trackback from your own site:

  1. Low Cost Domains Wed, 19 May 2010 03:02:21 GMT

    How long have you been in this field? You seem to know a lot more than I do, I’d love to know your sources!

  2. wga premie Thu, 11 Nov 2010 10:10:05 GMT

    A great idea but I wonder if this will be a big load to the server? wga premie

  3. webdesign terneuzen Sat, 13 Nov 2010 14:44:06 GMT

    It won’t be a big load on the server as its only a step.