The nice folks over on the Win32Utils group were kind enough to write
some code to do screen captures for us.
Watir can now take a copy of the screen ( or active window) and save it
to a jpg or a bmp file
Usage:
# this method saves the current window or whole screen as either a
bitmap or a jpeg
# It uses paint to save the file, so will barf if a duplicate filename
is selected, or the path doesnt exist etc
# * filename - string - the name of the file to save. If its
not fully qualified the current directory is used
# * active_window - boolean - if true, the whole screen is
captured, if false, just the active window is captured
# * save_as_bmp - boolean - if true saves the file as a bitmap,
saves it as a jpeg otherwise
def screen_capture(filename , active_window_only=false,
save_as_bmp=false)
ie.screen_capture(''c:\\pics\\screen_1.jpg) # does a copy of the whole
screen
ie.screen_capture(''c:\\pics\\screen_1.jpg) # does a copy of the whole
screen
ie.screen_capture(''c:\\pics\\screen_1.jpg , true ) # does a copy of
the active window
ie.screen_capture(''c:\\pics\\screen_1.bmp , tue , true ) # does a
copy
of the whole screen , saves as a bmp
Paul