Sha256: b82578c85b23b4b764b6168fe41d211eeb0d3f3bb97d03765a19244ac7775a11

Contents?: true

Size: 630 Bytes

Versions: 1

Compression:

Stored size: 630 Bytes

Contents

module Selenium
  module ScreenshotSaver
    
    def save_screenshot_to(png_path)
      dir = File.dirname(png_path)
      FileUtils.mkdir_p(dir) unless File.directory?(dir)
      if PLATFORM['darwin']
        sh "screencapture '#{png_path}'"
      elsif image_magick_support?
         sh "import -window root '#{png_path}'"        
      end
    end
    
    def image_magick_support?
      @image_magick_support ||= `import --version`.grep /"ImageMagick"/
    end
    
    def sh(command)
      system command
      STDERR.puts "Warning: Could not capture screenshot with '#{command}'" unless $? == 0
    end
    
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
selenium-client-1.1 lib/selenium/screenshot_saver.rb