January 1, 2012

Officially Introducing "SST" (Python Web Test Framework)

"SST (selenium-simple-test) is a framework built on Selenium WebDriver, using Python to make writing functional web tests easier with code."

Since early 2011, I have been working for Canonical on the Infrastructure Systems Development team (Core Dev Ops).

[pic of canonical-isd-hackers at UDS-P-Orlando]

A by-product of our recent development efforts is a web testing framework. It has been available on Launchpad for a while, but I've never really announced it in public. We are using SST internally, and I want to expose it to a wider audience.

What is Selenium WebDriver?

Selenium (WebDriver) is a popular open-source library for automating browsers. It can be used to create functional/acceptance tests of a web application. The Selenium client bindings provide API's that allow you to programatically drive a browser and access web content/elements. The bindings are available and supported for many languages and platforms.

While working directly with Selenium API's from code is fine for ad-hoc browser interaction, it is rather low-level and lacks things necessary for creating suites of automated web tests. For larger-scale testing, you will soon want to use a framework to help organize, execute, and report.

Introducing SST...

SST Logo

SST aims to keep things simple.

Tests are made up of scripts, created by composing actions that drive a browser and assert conditions. You have the flexibility of the full Python language, along with a convenient set of functions to simplify web testing.

SST framework consists of:

  • user actions and assertions (API) in Python
  • test case loader (generates/compiles scripts to unittest cases)
  • console test runner
  • data parameterization/injection
  • selectable output reports
  • selectable browsers
  • headless (xvfb) mode
  • screenshots on errors

Test output can be displayed to the console, saved as an HTML report, or JUnit-compatible XML for compatibility with CI systems.

SST is free open source software (Apache Licensed). SST is primarily being developed on Linux, specifically Ubuntu. It should work fine on other platforms, but any issues (or even better - patches) should be reported on the Launchpad project:

I just uploaded SST 0.1.0 to PyPI:

go ahead, give it a try:

  • `$ [sudo] pip install sst`

documentation and more info:

a sample test script in SST:

from sst.actions import *

go_to('http://www.ubuntu.com/')
assert_title_contains('Ubuntu homepage')

Here is the development progress of SST (shown as a code_swarm visualization) over the past 8 months:

Special thanks to all the SST code committers so far:

  • Danny Tamez
  • Julien Funk
  • Kenneth Koontz
  • Leo Arias
  • Lukasz Czyzykowkski
  • Rick McBride
  • Sidnei da Silva

Extra special thanks to SST's initial creator:

  • Michael Foord

Happy New Year!

-Corey Goldberg

5 comments:

MichaƂ Pasternak said...

Great job! Now I can get rid of the Makefile I used to perform the same thing :-) Looks great. Thank you for sharing this code!

Alex Kane said...

I ran in to a problem installing:

alex:~ alexkane$ pip install sst
Downloading/unpacking sst
Downloading sst-0.1.0.tar.gz (131Kb): 131Kb downloaded
Running setup.py egg_info for package sst
Traceback (most recent call last):
File "", line 14, in
File "/Users/alexkane/build/sst/setup.py", line 28, in
from sst import __version__
File "/Users/alexkane/build/sst/src/sst/__init__.py", line 28
except ImportError as e:
^
SyntaxError: invalid syntax
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

File "", line 14, in

File "/Users/alexkane/build/sst/setup.py", line 28, in

from sst import __version__

File "/Users/alexkane/build/sst/src/sst/__init__.py", line 28

except ImportError as e:

^

SyntaxError: invalid syntax

----------------------------------------
Command python setup.py egg_info failed with error code 1
Storing complete log in /Users/alexkane/.pip/pip.log

Corey Goldberg said...

Alex,
what version of Python are you using?

that traceback looks like it can't handle new-style [2.6+] exceptions.

SST requires Python 2.6 or 2.7.

-Corey

p.s. please use the Launchpad project for future bug reports and questions. feel free to post followup there. https://launchpad.net/selenium-simple-test

Unknown said...

Great job. Just write some random snippet to walk thru the tool. Everything works fine.

ruan keyu said...

There is statement in URL : http://testutils.org/sst :

You may optionally create a data file for data-driven testing. Create a ‘^’ delimited txt data file with the same name as the test, plus the ‘.csv’ extension. This will run a test using each row in the data file (1st row of data file is variable name mapping)

Could you list the detail steps regarding how to use this feature? Cause I did add the file and runner is able to recogonized it. But I do not know how to use the data in the file from code perspective. Could you give a example? Thanks!

But the way, Is there a best practical regarding how to orginize test data like: object id or xpath, test case relate data?

Best Regards,
Keyu Ruan