using twill for web application testing

Twill is a new python based scriptlet language for web application testing. I’ve been trying it out over the past few days and I’m finding it really useful for automating routine testing tasks during development. I can also see that it would be a great tool for test driven development.

The syntax is pretty simple:

>> go http://del.icio.us
==> at http://del.icio.us
current page: http://del.icio.us
>> showforms
Form #1
## __Name______ __Type___ __ID________ __Value__________
           all          text           searchbutton
1          submit       (None)         search
...
current page: http://del.icio.us
>> fv 1 all python
current page: http://del.icio.us
>> submit 1
current page: http://del.icio.us/search.?all=python

This example loads up the delicious site, reveals the forms in it, fills the search form box with the value ‘python’, and then submits it. You can run Twill from the command line for simple tests, or you can use it from within a python script by importing twill.commands.

Twill didn’t quite install correctly on OS X; I needed to manually copy the Mechanize and ClientCookie folders to site-packages. Once that was done though everything worked as expected; I’m using Activestate’s newish release of python 2.4 for OS X. After the installation I created a symbolic link to twill-sh in /usr/local/bin so that it’s always there when I need it.

On Windows Twill installed and ran without a hitch. The major difference is that you need to call ‘python twill-sh’ from the command line rather than just ’twill-sh’.


Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically each day to your feed reader.

No comments yet.

Sorry, the comment form is closed at this time.