Module: Selenium::WebDriver::DriverExtensions::TakesScreenshot
- Defined in:
- lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb
Instance Method Summary collapse
Instance Method Details
#save_screenshot(png_path) ⇒ Object
11 12 13 |
# File 'lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb', line 11 def save_screenshot(png_path) File.open(png_path, 'wb') { |f| f << screenshot_as(:png) } end |
#screenshot_as(format) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb', line 15 def screenshot_as(format) case format when :base64 bridge.getScreenshot when :png bridge.getScreenshot.unpack("m")[0] else raise Error::UnsupportedOperationError, "unsupported format: #{format.inspect}" end end |