Sha256: bb27bab7243b37dc33f0dd8072f4fa6630dcc203eda36f4434928ebc968ca147

Contents?: true

Size: 902 Bytes

Versions: 11

Compression:

Stored size: 902 Bytes

Contents

# encoding: utf-8
module Watir
  class Screenshot

    def initialize(driver)
      @driver = driver
    end

    #
    # Saves screenshot to given path.
    #
    # @example
    #   browser.screenshot.save "screenshot.png"
    #
    # @param [String] path
    #

    def save(path)
      @driver.save_screenshot(path)
    end

    #
    # Represents screenshot as PNG image string.
    #
    # @example
    #   browser.screenshot.png
    #   #=> '\x95\xC7\x8C@1\xC07\x1C(Edb\x15\xB2\vL'
    #
    # @return [String]
    #

    def png
      @driver.screenshot_as(:png)
    end

    #
    # Represents screenshot as Base64 encoded string.
    #
    # @example
    #   browser.screenshot.base64
    #   #=> '7HWJ43tZDscPleeUuPW6HhN3x+z7vU/lufmH0qNTtTum94IBWMT46evImci1vnFGT'
    #
    # @return [String]
    #

    def base64
      @driver.screenshot_as(:base64)
    end

  end # Screenshot
end # Watir

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
watir-webdriver-0.7.0 lib/watir-webdriver/screenshot.rb
watir-webdriver-0.6.11 lib/watir-webdriver/screenshot.rb
watir-webdriver-0.6.10 lib/watir-webdriver/screenshot.rb
watir-webdriver-0.6.9 lib/watir-webdriver/screenshot.rb
watir-webdriver-0.6.8 lib/watir-webdriver/screenshot.rb
watir-webdriver-0.6.7 lib/watir-webdriver/screenshot.rb
watir-webdriver-0.6.6 lib/watir-webdriver/screenshot.rb
watir-webdriver-0.6.5 lib/watir-webdriver/screenshot.rb
watir-webdriver-0.6.4 lib/watir-webdriver/screenshot.rb
watir-webdriver-0.6.3 lib/watir-webdriver/screenshot.rb
watir-webdriver-0.6.2 lib/watir-webdriver/screenshot.rb