Class: Watir::Screenshot

Inherits:
Object show all
Defined in:
lib/watir-classic/screenshot.rb

Instance Method Summary collapse

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

#base64Object



23
24
25
# File 'lib/watir-classic/screenshot.rb', line 23

def base64
  Base64.encode64 png
end

#pngObject



15
16
17
18
19
20
21
# File 'lib/watir-classic/screenshot.rb', line 15

def png
  path = File.expand_path "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