[Wtr-general] Challenging Question!
sathees
forum-watir-users at openqa.org
Wed Mar 28 01:30:52 EDT 2007
what's wrong with the follwing script? At random point the save picture modal dialog hangs and the script waits for manual interaction for that modal and continues. I wanted to handle this by giving a timeout of 30 sec. and cancel the modal dialog and continue. Timeout is not happening. I guess this is because that is one the same thread. So I tried the a new thread for the Save function. but still the problem is same.
Any help appreciated.
begin
timeout(30) do |timeout_length|
t_start = Time.now
lnk = []
@@ie2.images.each {|image| lnk << image.src}
$imagename = []
i = 0
lnk.length.times do |x|
if (lnk[x].include? "bedbookers.com")
# do Nothing
elsif (lnk[x].include? "google")
# do Nothing
else
$imagename[i] = "#{$bb_id}" + "_" + "#{i}" + ".jpg"
@save_path = "F\:\\Get_Image\\image\\#{$imagename[i]}"
if File.exists?(@save_path)
puts " "
puts "Image already Exists in " + @save_path
$save_flag = "NO"
i = i + 1
else
if (@@ie2.image(:src, lnk[x]).hasLoaded?)
@@ie2.image(:src, lnk[x]).save(@save_path)
puts " "
puts "Image saved to " + "#{@save_path}"
i = i + 1
$save_flag = "YES"
else
puts 'Image did not Load . .. ...'
end
end
end
end
t_end = Time.now
puts t_end - t_start
end
rescue
puts $!
w = WinClicker.new
hwnd = w.getWindowHandle(/Picture/)
if (hwnd >= 1)
puts 'hwnd is ' + "#{hwnd}"
w.clickWindowsButton_hwnd(hwnd, "Cancel")
puts 'Button Cancel clicked'
end
end
More information about the Wtr-general
mailing list