Thursday, May 28, 2009

Playing with Watir - File Upload/Download component

In my last post I talked about WATIR integration with Rspec.

In our project, we had excel report download component. The challenge with Watir was to be able to download the excel file, save it and validate data against DB. Thanks to David Brown for his Excel Interface class library which is easy to implement. Next thing was to be able to save the file at any given location (always). None of the documented steps worked. The autoit dll supported by Watir was at the rescue. Au3Info.exe helps to identify IE control IDs. The following code snippet explains the rest:

After conquering file download, next was file upload. It was much easier coz Au3Info.exe was always their to figure IE control IDs. Using AutoIt documentation simplified it further.

WATIR rocks !!


Gonzalo said...

The big issue with that implementation is the use of AutoIt, what happen if the tests are run in Linux or Mac?, that just doesn't work.

Amit Kumar said...

I agree but it solves the problem on windows platform efficiently... for those platform selenium can give you what u want..
with selenium2 released things have become much simpler...