In the past I have used the screen capture module which uses Paint and
found it very effective for scanning hundreds of web pages for
cosmetic defects, with the downside that it didn't capture the whole
page. My workaround was to capture the bottom of the page too, which
resulted in overlaps for short pages, and gaps for very long pages.
Although not perfect, this was still a major time saver after a major
CSS change.
A colleague recently forwarded an old post that included a code
snippet (from david goodine) and unanswered questions about the SnagIt
COM interface.
Reading the COM documentation (see link below) I modified the code and
got it to capture a complete image of a scrollable webpage. I rolled
this into our smoke test script which runs after every build and
capture each and every page to the network drive. Post execution,
anyone on the QA or UA team can review the screen shots for fixes,
enhancements or scan for cosmetic issues.
Within the main script:
$screenCaptureFolder = 'C:\temp'
# This only has to be done once.
$ie.bring_to_front
$ie.maximize
screenCapture(yourdesiredfilename)
In your method library:
def screenCapture(filename)
# this method will use SnagIt to capture and save a screenshot to
a directory
require 'win32ole'
# create snagit ole object:
snagit = WIN32OLE.new('Snagit.ImageCapture')
# set properties for the capture
snagit.Input = 1 #capture a window
# arbitrary X & Y locations within the scrollable portion of the
browser.
snagit.InputWindowOptions.XPos = 350 # select XPosition for
window ID
snagit.InputWindowOptions.YPos = 350 # select YPosition for
window ID
snagit.InputWindowOptions.SelectionMethod = 3 # Capture window
under the X, Y point specified above.
snagit.AutoScrollOptions.StartingPosition = 3 # set scroll to top
and left
snagit.AutoScrollOptions.AutoScrollMethod = 3 # set autoscroll to
vertical and horizontal
snagit.Output = 2 #output to a file
snagit.OutputImageFile.Filename = filename
snagit.OutputImageFile.Directory = $screenCaptureFolder #
set directy where filename will be saved
snagit.OutputImageFile.FileNamingMethod= 1 # set naming method
to fixed
snagit.OutputImageFile.ColorDepth = 16 # set color depth
snagit.OutputImageFile.FileType = 3 # set file type to
jpeg
# do the capture
snagit.Capture
# verify that capture is done, then return
while !snagit.IsCaptureDone
if snagit.IsCaptureDone then
return
end
end
return
end # screenCapture
Download the SnagIt COM Server User's Guide from
http://www.techsmith.com/snagit/accessories/comserver.asp
To change the properties above for your needs, refer to the User Guide
which maps the options to the corresponding integers.
Confirmed on SnagIt Ver 8.2.3 (Com Server available after Ver 6.2 -
from TechSmith website)
I'm considering adding this to my over night regression scripts to
capture pages where an error has occurred so I can get a visual of
what happened the next morning.
Walt Mamed