Hi-

I followed Zeljko's examples on 
http://wiki.openqa.org/display/WTR/File+Downloads
to implement File Downloads from Internet Explorer.  In my script (see
below) once I get File Download popup, I tell it to focus on Save
buton, and then click it.  I tried identifying Save button using
"&Save"
"[CLASS:Button; INSTANCE:2]")
"Save"

It works, but inconsistently -- every now and then, when looping and
downloading maybe 5 files, my scripts get stuck at the File Download
popup, where Cancel button seems to be in focus.

I'm using:
ruby 1.8.7
watir 2.0.4
autoit v3.3.6.1 (32-bit)
IE 8.0 (32-bit)
Windows 7 (64-bit)


Any help would be appreciated,

-Mark


def save_file(filepath)
        puts "Saving #{filepath}"
        ai = WIN32OLE.new("AutoItX3.Control")

    ai.WinWait("File Download", "", 5) # 1) File Download, click &Save
        ai.ControlFocus("File Download", "", "[CLASS:Button; INSTANCE:2]")
    sleep 1
    #ai.ControlClick("File Download", "&Save", "left") #
"[CLASS:Button; INSTANCE:2]" should be same as "&Save"
        ai.ControlClick("File Download", "", "[CLASS:Button; INSTANCE:2]",
"left")

    ai.WinWait("Save As", "", 5) # 2) Save As, click Save
    sleep 1
    ai.ControlSend("Save As", "", "Edit1", filepath)
    ai.ControlClick("Save As", "", "&Save", "left")

        ai.WinWait("Confirm Save As", "", 5) # 3) Confirm Save As, click &Yes
(if file already exists)
        ai.ControlClick("Confirm Save As", "", "&Yes")

        ai.WinWait("Download complete", "", 5)  # 4) Download complete, click
Close
    ai.ControlClick("Download complete", "", "Close")
        puts "Download complete"
end


save_file(file) # call save_file form a loop, pass in file name

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

Reply via email to