installation.rst 4.25 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: SlimerJS 0.7 or greater to run your tests against Gecko (Firefox) instead of Webkit.

Note

A Ruby version of the casperjs executable is also available in the rubybin/ directory; in order to use the :index:`Ruby` version instead of the Python one:

$ ln -sf `pwd`/rubybin/casperjs /usr/local/bin/casperjs

Or using the ruby interpreter:

$ ruby /path/to/casperjs/rubybin/casperjs
CasperJS version 1.1-DEV at /path/to/casperjs/rubybin/casperjs, using PhantomJS version 1.7.0
...

Installing from Homebrew (OSX)

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

$ brew install casperjs

Installing from git

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

From a stable tag

$ git clone git://github.com/n1k0/casperjs.git
$ cd casperjs
$ git checkout tags/1.0
$ 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 --version
1.0

From the master branch

The master branch hosts the current development version of CasperJS.

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

To check your current installed version:

$ casperjs --version
1.1-DEV

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.