If you need to save all of the images from a webpage you can take advantage of the save method in Watir::Image. This is really easy to do as you can see in the code below.
require 'watir'
browser = Watir::IE.new
browser.goto('http://twitter.com')
idx = 0
# using the images collection, iterate through all of the images on a page
browser.images.each do |x|
idx += 1
# apparently the string accepted by the string method will not allow variable substitution
location = 'c:\tmp\file-' + idx.to_s + '.jpg'
x.save(location)
end
Site running on a free Atlassian Confluence Community License granted to OpenQA. Evaluate Confluence today.