Embedding Watir-WebDriver screenshots in Cucumber html results

Thanks to a colleague Rob Hunter from ThoughtWorks Melbourne, I now know how to embed Watir-WebDriver screenshots into Cucumber HTML reports, and it is super simple.

  After do |scenario|
    browser.driver.save_screenshot 'screenshot.png'
    embed 'screenshot.png', 'image/png'

See also: watirwebdriver.com/screenshots

Author: Alister Scott

Alister is an Excellence Wrangler for Automattic.

5 thoughts on “Embedding Watir-WebDriver screenshots in Cucumber html results”

  1. Hi,
    Ive just tried this out, and it does work, however if you have more than 1 failure it embeds the same screenshot for all the failures, which as you can imagine is quite misleading. I am trying to come up with a simple way of doing this, will let you guys know if I work it out.



  2. It works well. However, I want to remind others who use this trick to pay attention to the relative folder path. You must put the screenshot png files’ relative path from the html file, not the relative path from the folder where you run cucumber. I know it is simple. However, it is easy to ignore this detail.


    1. I mean, I was able to shoot the Jenkins build email with screenshots attached to the report.


Comments are closed.