A reader has asked about automating Internet Explorer (IE) with Ruby. While you can do this using the win32ole library, I strongly recommend using the watir library instead.
WATIR (pronounced "water") stands for "Web Application Testing in Ruby". Watir is "a free, open-source functional testing tool for automating browser-based tests of web applications." Though it's designed for driving IE to test web applications, Watir is also very handy for automating IE in non-test scenarios. It leverages the win32ole library under the hood, but provides objects and methods that simplify the process.
To use Watir, first install the watir gem. Open up a Command Prompt and type the following...
gem install watir
...then, in your script, require the watir library...
require 'watir'
To create an instance of IE and navigate to a website...
ie = Watir::IE.new
ie.goto('http://rubyonwindows.blogspot.com')
To click on a link...
ie.link(:text, "win32ole").click
ie.link(:url, 'http://rubyonwindows.blogspot.com/search/label/win32ole').click
To input text into a text field...
ie.text_field(:name, 'login').set('MyLogin')
To select an option from a drop-down list...
ie.select_list( :name , "HallOfFame").select("Dave Concepcion")
To click a button...
ie.button(:value, 'Submit').click
To close the browser, call the close method...
ie.close
That's the basics. For further details and examples, you'll definitely want to check out the Watir User Guide.
For the complete Watir API reference, check out the rdocs here.
Various extensions for Watir have popped up, including WatirRecorder, WatirMaker, and WET Web Tester. Google for further details and updated links.
As always, post a comment here or send me an email with further questions or to request a topic for discussion.
Thanks for stopping by!