Sha256: 2229a15c37b51db9d1947e910a87b96cd76540c387af4d5c9869c089bd712d28

Contents?: true

Size: 964 Bytes

Versions: 8

Compression:

Stored size: 964 Bytes

Contents

class OperaWatir::Screenshot

  attr_accessor :browser, :reply

  def initialize(parent)
    self.browser = parent.browser
    self.reply   = driver.saveScreenshot(2, [].to_java(:string))
  end

  # Saves screenshot to specified location.
  #
  # @param [String]  Path to where you want the screenshot saved.
  # @return [String] The full path to the file that was saved.
  def save(filename)
    File.open(filename, 'w') { |f| f.write png }
    File.expand_path filename
  end

  # Is the screenshot blank?
  #
  # @return [Boolean] True/false depending on the screenshot is blank.
  def blank?
    reply.isBlank
  end

  # Returns the raw byte string of the screenshot in PNG format.
  #
  # @return [String] A png image in a raw byte string.
  def png
    String.from_java_bytes reply.getPng
  end

  # Lets you get a MD5 sum of the screen.
  #
  # @return [String] A hash. 
  def md5
    reply.getMd5
  end

private

  def driver
    browser.driver
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
operawatir-0.4.3.pre1-jruby lib/operawatir/screenshot.rb
operawatir-0.4.2-jruby lib/operawatir/screenshot.rb
operawatir-0.4.1-jruby lib/operawatir/screenshot.rb
operawatir-0.4.1.pre7-jruby lib/operawatir/screenshot.rb
operawatir-0.4.1.pre6-jruby lib/operawatir/screenshot.rb
operawatir-0.4.1.pre5-jruby lib/operawatir/screenshot.rb
operawatir-0.4.1.pre4-jruby lib/operawatir/screenshot.rb
operawatir-0.4.1.pre3-jruby lib/operawatir/screenshot.rb