Book Image

PhantomJS Cookbook

By : Rob Friesel
Book Image

PhantomJS Cookbook

By: Rob Friesel

Overview of this book

Table of Contents (15 chapters)
PhantomJS Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Detecting visual regressions using PhantomCSS


This recipe introduces the PhantomCSS library for CasperJS and illustrates how to test for visual regressions in web pages.

Getting ready

To run this recipe, the CasperJS binary must be installed and on our PATH; we will also need a script that expects to use the CasperJS API to navigate to and inspect a web page.

We will need the PhantomCSS library, and we will need to make it available to our CasperJS script.

Note

PhantomCSS is a module for CasperJS that can automate visual regression testing. It is an open source (MIT licensed) project and is available at the following GitHub repository at https://github.com/Huddle/PhantomCSS.

Tip

The PhantomCSS script is available in the downloadable code repository as lib/phantomcss/phantomcss.js.

The script in this recipe is available in the downloadable code repository as recipe10.js under chapter05. If we run the provided example script, we must change to the root directory for the book's sample code.

Lastly,...