O'Reilly logo

Instant Testing with CasperJS by Éric Bréhault

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Getting started with CasperJS (Simple)

This recipe will explain how to write basic CasperJS tests and will help us get familiar with the CasperJS approach.

Getting ready

In this recipe, we will build simple web pages in order to run our CasperJS tests in an appropriate context.

As we need to serve just static content (HTML, CSS, JavaScript), we need a very basic HTTP server and the simplest existing HTTP server is the Python 2 SimpleHTTTPServer, as it is part of the standard Python installation (so that no extra deployment is needed), and it does not need any system configuration.

On Mac OS X and Linux, Python 2 is part of the system; we just launch the following command line from the folder containing our web content:

~ python -m SimpleHTTPServer ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required