O'Reilly logo

An Introduction to Testing Web Applications with twill and Selenium by Jason Huggins, Gheorghe Gheorghiu, C. Titus Brown

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

  1. Install Django (see http://www.djangoproject.com/documentation/install/).

  2. Download the demonstration app, at http://webtesting.idyll.org/resources/django-poll.zip.

  3. Unpack django-poll.zip (it will unpack into a subdirectory named django-poll) and change into the mysite sub-directory.

  4. Run python manage.py runserver. It will start a web server on http://localhost:8000; to make sure that it is running, visit http://localhost:8000/polls.

You're done!

The First Step: Charting a Path to Test

After you have the Django application ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required