Skip to content

Instantly share code, notes, and snippets.

@pmoran
Created Dec 13, 2010
Embed
What would you like to do?
# Ripped from cucumber-0.8.3/examples/watir/features/support/screenshots.rb
module Screenshots
if Cucumber::OS_X
def embed_screenshot(id)
`screencapture -t png reports/#{id}.png`
embed("#{id}.png", "image/png")
end
else
def embed_screenshot(id)
`import -window root reports/#{id}.png`
embed("#{id}.png", "image/png")
end
end
end
World(Screenshots)
After do |scenario|
if scenario.failed? && defined?(Capybara) && Capybara.current_session
embed_screenshot("screenshot-#{Time.new.to_i}")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment