class Watir::Screenshot
Public Class Methods
new(browser)
click to toggle source
# File lib/watir/screenshot.rb, line 3 def initialize(browser) if browser.is_a? Selenium::WebDriver::Driver msg = 'Initializing `Watir::Screenshot` with a `Selenium::Driver` instance', 'a `Watir::Browser` instance' Watir.logger.deprecate msg, ids: [:screenshot_driver] @driver = browser else @browser = browser @driver = browser.wd end end
Public Instance Methods
base64()
click to toggle source
Represents screenshot as Base64 encoded string.
@example
browser.screenshot.base64 #=> '7HWJ43tZDscPleeUuPW6HhN3x+z7vU/lufmH0qNTtTum94IBWMT46evImci1vnFGT'
@return [String]
# File lib/watir/screenshot.rb, line 51 def base64 @driver.screenshot_as(:base64) end
png()
click to toggle source
Represents screenshot as PNG image string.
@example
browser.screenshot.png #=> '\x95\xC7\x8C@1\xC07\x1C(Edb\x15\xB2\vL'
@return [String]
# File lib/watir/screenshot.rb, line 37 def png @driver.screenshot_as(:png) end
save(path)
click to toggle source
Saves screenshot to given path.
@example
browser.screenshot.save "screenshot.png"
@param [String] path
# File lib/watir/screenshot.rb, line 23 def save(path) @driver.save_screenshot(path) end