lib/watirsplash/html_formatter.rb in watirsplash-0.2.0 vs lib/watirsplash/html_formatter.rb in watirsplash-0.2.1
- old
+ new
@@ -1,7 +1,7 @@
require 'spec/runner/formatter/html_formatter'
-require 'win32screenshot'
+require 'win32/screenshot'
require 'rmagick'
require 'pathname'
require 'fileutils'
module WatirSplash
@@ -69,14 +69,15 @@
end
def save_screenshot(description="Screenshot", hwnd=@browser.hwnd) # :nodoc:
begin
@browser.bring_to_front
- width, height, blob = Win32::Screenshot.capture_hwnd(hwnd)
- file_name = file_path("screenshot.png", description)
- img = Magick::ImageList.new
- img.from_blob(blob)
- img.write(file_name)
+ Win32::Screenshot.hwnd(hwnd) do |width, height, blob|
+ file_name = file_path("screenshot.png", description)
+ img = Magick::ImageList.new
+ img.from_blob(blob)
+ img.write(file_name)
+ end
rescue => e
$stderr.puts "saving of screenshot failed: #{e.message}"
$stderr.puts e.backtrace
end
file_name
\ No newline at end of file