Skip to content

QualityEnablement/needle

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

194 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Needle

Build Status

Needle is a tool for testing visuals with Selenium and nose.

It checks that visuals (CSS/fonts/images/SVG/etc.) render correctly by taking screenshots of portions of a website and comparing them against known good screenshots. It also provides tools for testing calculated CSS values and the position of HTML elements.

Example

This is what a Needle test case looks like:

from needle.cases import NeedleTestCase

class BBCNewsTest(NeedleTestCase):
    def test_masthead(self):
        self.driver.get('http://www.bbc.co.uk/news/')
        self.assertScreenshot('#blq-mast', 'bbc-masthead')

This example checks for regressions in the appearance of the BBC's masthead.

Documentation

Full documentation available on Read the Docs.

This forked repo has some added features such as masking an element to be ignored for image comparison. Refer to the Additional Features section below.

If you'd like to build the documentation yourself, first install sphinx:

pip install sphinx

Then run:

cd docs
make html

The documentation will then be available browsable from docs/_build/index.html.

Running Needle's test suite

First install tox (usually via pip install tox). Then:

$ tox

Additional Features

Exclude elements for image comparison.

from needle.cases import NeedleTestCase
from selenium.webdriver.common.by import By

class BBCNewsTest(NeedleTestCase):
    def test_masthead(self):
        self.driver.get('http://www.bbc.co.uk/news/')
        self.assertScreenshot('#blq-mast', 'bbc-masthead', exclude=[(By.ID, 'page-title')])

Refer to assertScreenshot and compareScreenshot methods in cases.py for more details.

About

Automated tests for your CSS.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%