Sha256: 458629c1404a35c2e4be2a1bc4a075a12483da945073e9dd15ada6709b599b84

Contents?: true

Size: 706 Bytes

Versions: 3

Compression:

Stored size: 706 Bytes

Contents

module CukePack
  class << self
    attr_accessor :screenshot_options
  end

  self.screenshot_options = { :width => 1280, :height => 1024, :prepend_driver_name => true, :directory => "features/screenshots" }
end

def take_screenshot(name, options = {})
  selenium = Capybara.current_session.driver.browser

  if selenium.respond_to?(:manage)
    options = CukePack.screenshot_options.merge(options)

    selenium.manage.window.resize_to(options[:width], options[:height])

    target = options[:directory]
    target = File.join(target, Capybara.current_driver.to_s)
    target = File.join(target, name + ".png")

    FileUtils.mkdir_p File.dirname(target)

    selenium.save_screenshot(target)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cuke-pack-0.0.3 lib/cuke-pack/support/screenshots.rb
cuke-pack-0.0.2 lib/cuke-pack/support/screenshots.rb
cuke-pack-0.0.1 lib/cuke-pack/support/screenshots.rb