Jump to content
Sign in to follow this  

AutoIt and Watir File Download problem

Recommended Posts

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'


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")


Download","","[CLASS:Button;TEXT:&Save;INSTANCE:2]") #clicking Save


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 //-->

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...