Introduction to Functional Web Testing With Twill & Selenium

Part 1 :: Introduction :: Everyone set up?

Synopsis

Get up everyone up and running with the tools required to complete the tutorial.

Introduction [Minutes 0 - 15]

Python

It kind of wouldn't be a Python tutorial without our trusty friend Python.

              [terryp@tpmacbook] ~ :: python --version
              Python 2.5.4
              [terryp@tpmacbook] ~ :: python
              Python 2.5.4 (r254:67917, Dec 23 2008, 14:57:27)
              [GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
              Type "help", "copyright", "credits" or "license" for more information.
              >>>
            

Download Python

Python on Windows

Yes, Windows users make it a little trickier.

If you're on Cygwin, Python should be installed in a specific location.

If you install Python straight, then we need to add Python to your PATH, like this:

  • Right click on 'My Computer'
  • Select 'Settings'
  • Select 'Advanced'
  • Select 'Environment Variables'
  • Edit PATH entry and append location of Python install (e.g. C:\Python25\)
  • Click 'OK'
  • Start > Run > 'cmd'
  • Type 'python'
  • Ctrl + Z + RETURN to quit and Ctrl + Break to stop our little webserver.

Download Python

Nose

Nose is our preferred test runner.

              [terryp@tpmacbook] ~ :: nosetests --version
              nosetests version 0.10.4
              [terryp@tpmacbook] ~ ::
            

Download Nose | Local .tar.gz

Twill

Twill is what we're going to use to navigate our site.

              [terryp@tpmacbook] ~ :: twill-sh --version
              twill version 0.9.
              [terryp@tpmacbook] ~ ::
            

Download Twill | Local .tar.gz

BeautifulSoup

BeautifulSoup is our HTML parser of choice.

              [terryp@tpmacbook] ~ :: python
              Python 2.5.4 (r254:67917, Dec 23 2008, 14:57:27)
              [GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
              Type "help", "copyright", "credits" or "license" for more information.
              >>> import BeautifulSoup
              >>> print BeautifulSoup.__version__
              3.1.0.1
              >>>
            

Download BeautifulSoup | Local .tar.gz

Selenium IDE

Selenium IDE is a Firefox extension to record and playback tests.

Download Selenium IDE | Local .xpi

Selenium RC

Selenium RC (Remote Control) is a package that will allow us to programmatically interact with Selenium.

Let's start the server:

              [terryp@tpmacbook] selenium-server-1.0-beta-2 :: java -jar selenium-server.jar
              22:45:40.843 INFO - Java: Apple Inc. 1.5.0_16-133
              22:45:40.879 INFO - OS: Mac OS X 10.5.6 i386
              22:45:40.883 INFO - v1.0-beta-2 [2571], with Core v1.0-beta-2 [2330]
              22:45:41.086 INFO - Version Jetty/5.1.x
              22:45:41.087 INFO - Started HttpContext[/,/]
              22:45:41.088 INFO - Started HttpContext[/selenium-server,/selenium-server]
              22:45:41.088 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
              22:45:41.131 INFO - Started SocketListener on 0.0.0.0:4444
              22:45:41.131 INFO - Started org.mortbay.jetty.Server@bc887b
            

Let's run a built-in test:

              [terryp@tpmacbook] selenium-python-client-driver-1.0-beta-2 :: nosetests test_default_server.py
              .
              ----------------------------------------------------------------------
              Ran 1 test in 9.520s
              
              OK
              [terryp@tpmacbook] selenium-python-client-driver-1.0-beta-2 ::
            

And now let's stop the server by hitting Ctrl + c:

              ...
              22:50:29.117 INFO - Command request: testComplete[, ] on session 7ac64e302c39437daf252f2b14e63b84
              22:50:29.118 INFO - Killing Firefox...
              22:50:29.151 INFO - Got result: OK on session 7ac64e302c39437daf252f2b14e63b84
              ^C22:51:34.210 INFO - Shutting down...
              [terryp@tpmacbook] selenium-server-1.0-beta-2 ::
            

Download Selenium RC | Local .zip

 

on to the overview

Fluid 960 Grid System, created by Stephen Bau, based on the 960 Grid System by Nathan Smith. Released under the GPL/ MIT Licenses.