rickrod Posted July 31, 2007 Posted July 31, 2007 Hi everyone. I am new here and new to Ruby and Watir. I was wondering if there was someone here who might be able to help me with completing a task. I am trying to automate a process of downloading a file from a website. Nothing major I am just trying to figure out how to do this. I have been to many other forums for information but it seems that people, for the most part, are not able to sort this out. The problem I am having is that when it clicks on the link to download the file, the application just hangs and the file dialog box just stays open. I need it to just click on the "Save" button and save the file... Can anyone help? Here is what I have... <!-- script starts //--> require 'watir' # the watir controller require 'win32ole' test_site = 'www.rickrodriguezjr.com/test.html' ie.goto(test_site) sleep 10 ie.link(:text, "here").click puts "Sleeping for 10" sleep 15 puts "Comming out of sleep" autoit = WIN32OLE.new('AutoItX3.Control') autoit.WinWaitActive("File Download") #File Download popup autoit.ControlFocus("File Download","","32770") autoit.ControlClick("File Download","","[CLASS:Button;TEXT:&Save;INSTANCE:2]") #clicking Save button autoit.WinWaitActive("Save As") #catching the Save As popup autoit.Send("file_name") #sending file name into window autoit.ControlClick("Save As", "", "[CLASS:Button;TEXT:&Save;INSTANCE:2]") #clicking Save button autoit.WinWaitActive("Download") #catching Download popup autoit.ControlClick("Download", "", "[CLASS:Button;TEXT:&Open;INSTANCE:2]") #opening the downloaded file puts "Ending" sleep 20 <!-- end script //-->
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now