public
Description: Is it possible to write tests against CSS?
Homepage:
Clone URL: git://github.com/garethr/css-test.git
Alexander Kahn (author)
Wed Dec 17 09:39:49 -0800 2008
garethr (committer)
Sun Dec 21 03:26:08 -0800 2008
name age message
file .gitignore Sat Nov 22 04:32:18 -0800 2008 ignore sample folder in gitignore [garethr]
file README Sat Nov 29 08:15:01 -0800 2008 trying to merge in changes [garethr]
directory ext/ Sat Nov 22 13:58:17 -0800 2008 first experiments with selenium for DOM value t... [garethr]
file test_dom.py Sat Nov 22 13:58:17 -0800 2008 first experiments with selenium for DOM value t... [garethr]
file test_image.py Sun Dec 21 03:26:08 -0800 2008 Fixed spelling error. 'their' -> 'there' Signe... [Alexander Kahn]
README
CSS is hard to test automatically. There appear to be two potential approaches 
which might have merit in solving this problem and this sample code 
represents one of them.

test_image.py

The basic idea here revolves around programatic comparison of images, some
based on  screen shots and others generated dynamically from URLs. The
capability to analyse only a segment of a page has also been included.

The overhead introduced by the need to take screenshots of a site makes this
technique more useful for spotting regression issues in a live site than for
a test driven approach to writing CSS. Tools will be provided to make this 
easier at a later date.

As this is currently a proof of concept in that it only supports testing in 
webkit, and even then only on OS X. Support for other browsers relies on 
other screen grab tools being integrated into the code.

This is not intended as a tool to check whether a finished website looks
identical to a set of photoshop images. It's intended to spot changes in
unexpected areas of a site's layout or design.

test_dom.py

Here we plan on using Selenium to extract rendered DOM values such as text-size from a given web page and compare them 
against expected values. This could be useful both for regression testing and for assertion based test driven 
development.

The sample code is written in Python but other implementations would be
straightforward. Much of the actual work is done via other commands; namely 
webkit2png by Paul Hammond and the Imagemagik suite of tools.