installation.rst 4.16 KB

Installation

CasperJS can be installed on most Linuxes, OSX and Windows.

Prerequisites

  • PhantomJS 1.8.1 or greater. Installation instructions can be found here
  • Python 2.6 or greater
  • Experimental: as of 1.1-beta1, SlimerJS 0.8 or greater to run your tests against Gecko (Firefox) instead of Webkit. To see PhantomJS API compatibility of SlimerJS, please refer to this page.

Warning

The Ruby version of the casperjs executable also available in the rubybin/ directory has been deprecated as of 1.1-beta, and is not compatible with SlimerJS.

Installing from Homebrew (OSX)

Installation of both PhantomJS and CasperJS can be achieved through Homebrew.

For the 1.1 development version (recommended):

$ brew install casperjs --devel

For the 1.0.x stable version:

$ brew install casperjs

Installing from git

Installation can be achieved using git. The code is mainly hosted on Github.

From the master branch

$ git clone git://github.com/n1k0/casperjs.git
$ cd casperjs
$ ln -sf `pwd`/bin/casperjs /usr/local/bin/casperjs

Once PhantomJS and CasperJS installed on your machine, you should obtain something like this:

$ phantomjs --version
1.8.2
$ casperjs
CasperJS version 1.1.0-DEV at /Users/niko/Sites/casperjs, using phantomjs version 1.9.0
# ...

Or if SlimerJS is your thing:

$ slimerjs --version
Innophi SlimerJS 0.8pre, Copyright 2012-2013 Laurent Jouanneau & Innophi
$ casperjs
CasperJS version 1.1.0-DEV at /Users/niko/Sites/casperjs, using slimerjs version 0.8.0

You are now ready to write your :doc:`first script <quickstart>`!

Installing from an archive

You can download tagged archives of CasperJS code:

Latest stable version:

Latest development version (master branch):

Operations are then the same as with a git checkout.

CasperJS on Windows

Phantomjs installation additions

  • Append ";C:\phantomjs" to your PATH environment variable.
  • Modify this path appropriately if you installed PhantomJS to a different location.

Casperjs installation additions

CasperJS, as of 1.0.0-RC3, ships with a Batch script so you don't need Python nor Ruby to use it.

  • Append ";C:\casperjs\batchbin" to your PATH environment variable.
  • Modify this path appropriately if you installed CasperJS to a different location.

You can now run any regular casper scripts that way:

C:> casperjs.bat myscript.js

Earlier versions of CasperJS

Before 1.0.0-RC3, you had to setup your casper scripts that way:

phantom.casperPath = 'C:\\casperjs-1.1';
phantom.injectJs(phantom.casperPath + '\\bin\\bootstrap.js');

var casper = require('casper').create();

// do stuff

Run the script using the phantom.exe program:

C:> phantomjs.exe myscript.js

Note

There is no output coloration when running CasperJS on Microsoft platforms.

Known Bugs & Limitations

  • Due to its asynchronous nature, CasperJS doesn't work well with PhantomJS' REPL.