Class: Watir::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/watir/extensions/element/screenshot.rb

Instance Method Summary collapse

Instance Method Details

#screenshot(dest) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/watir/extensions/element/screenshot.rb', line 6

def screenshot(dest)
  file = Tempfile.new('sc')
  begin
    browser.screenshot.save(file)
    image = ChunkyPNG::Image.from_file(file)
    image.crop!(wd.location.x + 1, wd.location.y + 1, wd.size.width, wd.size.height)
    image.save(dest)
  ensure 
    file.unlink 
  end
end