Class: SparklingWatir::Screenshot

Inherits:
Object
  • Object
show all
Defined in:
lib/sparkling_watir/screenshot.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(driver) ⇒ Screenshot

Returns a new instance of Screenshot.



5
6
7
# File 'lib/sparkling_watir/screenshot.rb', line 5

def initialize(driver)
  @driver = driver
end

Instance Attribute Details

#driverObject (readonly)

Returns the value of attribute driver.



3
4
5
# File 'lib/sparkling_watir/screenshot.rb', line 3

def driver
  @driver
end

Instance Method Details

#base64String

Represents screenshot as Base64 encoded string.

Examples:

driver.screenshot.base64
#=> '7HWJ43tZDscPleeUuPW6HhN3x+z7vU/lufmH0qNTtTum94IBWMT46evImci1vnFGT'

Returns:

  • (String)


46
47
48
# File 'lib/sparkling_watir/screenshot.rb', line 46

def base64
  driver.screenshot_as(:base64)
end

#pngString

Represents screenshot as PNG image string.

Examples:

driver.screenshot.png
#=> '\x95\xC7\x8C@1\xC07\x1C(Edb\x15\xB2\vL'

Returns:

  • (String)


32
33
34
# File 'lib/sparkling_watir/screenshot.rb', line 32

def png
  driver.screenshot_as(:png)
end

#save(path) ⇒ Object

Saves screenshot to given path.

Examples:

driver.screenshot.save "screenshot.png"

Parameters:

  • path (String)


18
19
20
# File 'lib/sparkling_watir/screenshot.rb', line 18

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