Visual testing frameworks
PhantomCSS uses PhantomJS for screenshot differencing. PhantomCSS won’t integrate directly with the Django live server or your Python test suite, so if you want to run a visual integration test, you’d need to manually start and stop the test server between tests. I might eventually try out PhantomCSS for CSS unit tests, but I wanted to visually test my full website so I needed integration with the Django live server.
The needle Python library uses Selenium to navigate your website and screenshot rendered pages. Unfortunately needle has poor test coverage, a seemingly failing test suite, and no change log. Despite these shortcomings, I went with needle for my visual integration tests because it got the job done.
Django and Needle
I used the following mixin to integrate the Django live server with needle. I used PhantomJS, but Firefox or another Selenium web driver should work as well.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Unfortunately the above code only works with the version of needle on Github. The PyPI version does not yet include the
NeedleWebDriverMixin (which I contributed recently for Django support). I have created an issue suggesting a new PyPI release be made to resolve this problem.
Room for improvement
Currently I only run my visual tests manually. Visual tests are very brittle and occasionally they just break without any changes. If I manage to stabilize my visual tests so that they pass consistently on different platforms, I may run them during continuous integration.
Do you have another solution for visual integration testing? Let me know in the comments.