Class: Watir::Screenshot
Instance Method Summary collapse
- #base64 ⇒ Object
-
#initialize(browser_hwnd) ⇒ Screenshot
constructor
A new instance of Screenshot.
- #png ⇒ Object
- #save(path) ⇒ Object
Constructor Details
#initialize(browser_hwnd) ⇒ Screenshot
Returns a new instance of Screenshot.
7 8 9 |
# File 'lib/watir-classic/screenshot.rb', line 7 def initialize(browser_hwnd) @hwnd = browser_hwnd end |
Instance Method Details
#base64 ⇒ Object
23 24 25 |
# File 'lib/watir-classic/screenshot.rb', line 23 def base64 Base64.encode64 png end |
#png ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/watir-classic/screenshot.rb', line 15 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
11 12 13 |
# File 'lib/watir-classic/screenshot.rb', line 11 def save(path) screenshot.write(path) end |