How can I save site images using watir without reloading them with open uri or similar?
I: The reason I canβt use
File.open(file_name, 'wb') do |f| f.write open(img.src).read end
lies in the fact that images are generated in the current session (login-) and only once, so the "external" 2nd access is impossible.
II: browser.images.save() - only for ie - is also not useful, it opens a save dialog. So it is useless for automation.
Examples: http://wiki.openqa.org/display/WTR/Save+All+Images+on+a+Webpage
require 'watir' browser = Watir::Browser.new :ie browser.goto 'http://google.com' idx = 0 browser.images.each do |x| puts idx idx += 1 location = 'c:\tmp\file-' + idx.to_s + '.jpg' x.save(location) end
github source: http://rubydoc.info/github/watir/watir-classic/Watir/Image
My best idea for atm is to get all images using a proxy. But maybe there is a vari-way.
Environment:
# ruby 1.9.3p125 (2012-02-16) [i386-mingw32] # watir (4.0.2 x86-mingw32) # watir-classic (3.6.0, 3.5.0, 3.4.0) # watir-webdriver (0.6.4, 0.6.2)
Edit: I know there are different ways to get images from a website, and without taking into account events, I could create a list with so many solutions, but he decided to solve the problem using watir .
source share