Sha256: 15571d7676d4011f91026b27dab42d6b2aca2a1e5177bed45c40cfb6fc74254c

Contents?: true

Size: 1010 Bytes

Versions: 13

Compression:

Stored size: 1010 Bytes

Contents

# This is an example of how you can set up screenshots for your
# browser testing. Just run cucumber with --format html --out report.html
#
# This examples currently only works on OS X, but adding support for other
# platform should be easy - as long as there is a command line tool to take
# a picture of the desktop.
module Screenshots
  def add_screenshot
    id = "screenshot-#{Time.new.to_i}"
    take_screenshot(id)
    embed("#{id}.png", "image/png")
  end

  if Cucumber::OS_X
    def take_screenshot(id)
      `screencapture -t png #{id}.png`
    end
  else
    # Other platforms...
    def take_screenshot(id)
      STDERR.puts "Sorry - no screenshots on your platform yet."
    end
  end
end

After do
  add_screenshot
end

# Other variants
#
# Only take screenshot on failures
#
#   After do |scenario|
#     add_screenshot if scenario.failed?
#   end
#
# Only take screenshot for scenarios or features tagged @screenshot
#
#   After(@screenshot) do
#     add_screenshot
#   end

World(Screenshots)

Version data entries

13 entries across 13 versions & 4 rubygems

Version Path
cucumber-0.5.3 examples/watir/features/support/screenshots.rb
cucumber-0.5.2 examples/watir/features/support/screenshots.rb
cucumber-0.5.1 examples/watir/features/support/screenshots.rb
cucumber-0.5.0 examples/watir/features/support/screenshots.rb
cucumber-0.4.5.rc2 examples/watir/features/support/screenshots.rb
kbaum-cucumber-0.4.5.pre examples/watir/features/support/screenshots.rb
cucumber-0.4.5.rc1 examples/watir/features/support/screenshots.rb
middleman-0.10.17 vendor/gems/gems/cucumber-0.4.4/examples/watir/features/support/screenshots.rb
middleman-0.10.16 vendor/gems/gems/cucumber-0.4.4/examples/watir/features/support/screenshots.rb
middleman-0.10.15 vendor/gems/gems/cucumber-0.4.4/examples/watir/features/support/screenshots.rb
rackjour-0.1.8 vendor/gems/gems/cucumber-0.4.4/examples/watir/features/support/screenshots.rb
middleman-0.10.14 vendor/gems/gems/cucumber-0.4.4/examples/watir/features/support/screenshots.rb
cucumber-0.4.4 examples/watir/features/support/screenshots.rb