Screenshots  

Watir has a pretty awesome screenshot capability, built right in.

# Save screenshot to file
browser.screenshot.save 'screenshot.png'

# Represent screenshot as PNG image string
browser.screenshot.png

# Represent screenshot as Base64 encoded string
browser.screenshot.base64

If you’re using Cucumber also, you can easily embed this in your html report output by adding the following to your env.rb file:

After do |_scenario|
  browser.screenshot.save 'screenshot.png'
  embed 'screenshot.png', 'image/png'
end

Last Updated: November 27, 2018