Testing a Simple Web Application with twill and Selenium
The Django "poll" Application
In order to provide you with an example of how to use twill and Selenium to test an application, we're going to take advantage of the Django "poll" application that you build in the Django tutorial, at http://www.djangoproject.com/documentation/tutorial1/.
You don't actually need to go through the Django tutorial to read this section, you can download the source code django-poll-site.zip here. You don't need to know anything at all about Django, either; all you need to do is install Django, install the application, and then follow along below.
Before we get started, honesty compels us to admit that Django has
a pretty nice built-in testing framework,
django.test. However, that framework is
specific to Django—the testing techniques that we demonstrate below
apply to any framework in any
language, not just Django apps or web sites written in Python.
Installing and running the poll application
Install Django (see http://www.djangoproject.com/documentation/install/).
Download the demonstration app, at http://webtesting.idyll.org/resources/django-poll.zip.
django-poll.zip(it will unpack into a subdirectory named
django-poll) and change into the
python manage.py runserver. It will start a web server on
http://localhost:8000; to make sure that it is running, visit
The First Step: Charting a Path to Test
After you have the Django application ...