Class: Watir::Screenshot
- Inherits:
-
Object
- Object
- Watir::Screenshot
- Defined in:
- lib/watir-classic/screenshot.rb
Overview
Returned by Browser#screenshot.
Instance Method Summary collapse
-
#base64 ⇒ String
#png image formatted as base64.
-
#initialize(browser_hwnd) ⇒ Screenshot
constructor
A new instance of Screenshot.
-
#png ⇒ String
Image in png format.
-
#save(path) ⇒ Object
Save screenshot to the file.
Constructor Details
#initialize(browser_hwnd) ⇒ Screenshot
Returns a new instance of Screenshot.
8 9 10 |
# File 'lib/watir-classic/screenshot.rb', line 8 def initialize(browser_hwnd) @hwnd = browser_hwnd end |
Instance Method Details
#base64 ⇒ String
Returns #png image formatted as base64.
29 30 31 |
# File 'lib/watir-classic/screenshot.rb', line 29 def base64 Base64.encode64 png end |
#png ⇒ String
Returns image in png format.
20 21 22 23 24 25 26 |
# File 'lib/watir-classic/screenshot.rb', line 20 def png path = File. "temporary-image-#{Time.now.to_i}.png", Dir.tmpdir save path File.open(path, "rb") {|file| file.read} ensure File.delete path rescue nil end |
#save(path) ⇒ Object
Save screenshot to the file.
15 16 17 |
# File 'lib/watir-classic/screenshot.rb', line 15 def save(path) screenshot.write(path) end |