Python and IEC - Stupid-Simple Windows Browser Automation
Python and IEC - Stupid-Simple Windows Browser Automation
Submitted by Corey Goldberg on Tue, 10/04/2007 - 19:04.I have been using IEC lately for automating repetitive administrative tasks within my company:
IEC.py - Automating Internet Explorer with Python
IEC is a simple library with a nice API for automating an IE browser. I found it simple to work with for basic automation needs. I have also used it as the core of a small UI testing framework.
From Mayukh Bose:
IEC is a python library designed to help you automate and control an Internet Explorer window. You can use this library to navigate to web pages, read the values of various HTML elements, set the values of checkboxes, text boxes, radio buttons etc., click on buttons and submit forms.
Yeah I know.. pretty lame it only works with IE, but in the environment I was working in, the applications ran on *IE Only*.
A personal story:
My company is very analytical and detail oriented when it comes to tracking/planning project resource allocation. We track all sorts of projections, budgets, resources, etc. The workflow is basically: some business guys (no idea what they actually do) take data from some reports and enter them into some arcane hosted tracking software. This is done by entering copious amounts of data into web form after web form. Then they submit the form to run a report. Once that is finished, they cut & paste the data into MS Excel. Then they take the Excel spreadsheet and follow some wild sequence of copying, cutting, pasting, converting, running macros, graphing, etc. At the end of this, a few images are produced so some wizz-bang graphs can go into a monthly Powerpoint... wow.
So... I wrote a Python script that takes their input data, drives a web browser to do the report, screen scrapes the result, processes it, generates some fancy graphs with Matplotlib, and presents a web page with the results. End result: Converted a multi-hour manual process into the click of an icon and 20 seconds of processing.
I could have done this with HTTP directly, but this UI automation technique made it very quick to develop; and it looked impressive ("whoa it's like.. making my browser move on its own").
To use IEC, you need the Python for Windows Extensions. If you use the ActiveState Python distribution, these are already included.
I used to use ActiveState Python for Windows programming (because I was a big fan of ActiveState Perl, where the installer and PPM package manager rocked). I recently spent close to an hour getting SSL (HTTP) to work with ActiveState. I couldn't get it to work so I ditched it for the standard Python distro.
--
Happy Hacking.
