installation.rst 4.71 KB

Installation

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

Prerequisites

  • PhantomJS 1.8.2 or greater. Installation instructions can be found here
  • Python 2.6 or greater for casperjs in the bin/ directory
  • Experimental: as of 1.1-beta1, SlimerJS 0.8 or greater to run your tests against Gecko (Firefox) instead of Webkit (just add --engine=slimerjs to your command line options). To see PhantomJS API compatibility of SlimerJS, please refer to this page.

Installing from Homebrew (OSX)

Installation of both PhantomJS and CasperJS can be achieved using Homebrew, a popular package manager for Mac OS X.

Above all, don't forget to update Formulaes:

$ brew update

For the 1.1 development version (recommended):

$ brew install casperjs --devel

For the 1.0.x stable version:

$ brew install casperjs

If you have already installed casperjs and want to have the last release (stable|devel), use upgrade:

$ brew upgrade casperjs

Upgrade only update to the latest release branch (1.0.x|1.1-dev).

Installing from npm

You can install CasperJS using npm:

$ npm install -g casperjs

Note

The -g flag makes the casperjs executable available system-wide.

Warning

While CasperJS is installable via npm, :ref:`it's not a NodeJS package <faq_node>`, neither it's capable to require native NodeJS modules.

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.9.2
$ casperjs
CasperJS version 1.1.0-DEV at /Users/niko/Sites/casperjs, using phantomjs version 1.9.2
# ...

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 development version (master branch):

Latest stable version:

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

  • Append ";C:\casperjs\bin" to your PATH environment variable.
  • Modify this path appropriately if you installed CasperJS to a different location.
  • If your computer uses both discrete and integrated graphics you need to disable autoselect and explicitly choose graphics processor - otherwise exit() will not exit casper.

You can now run any regular casper scripts that way:

C:> casperjs myscript.js

Colorized output

Note

Windows users will get colorized output if ansicon is installed.

Compilation (Optionaly)

  • .NET Framework 3.5 or greater (or Mono 2.10.8 or greater) for casperjs.exe in the bin/ directory

Known Bugs & Limitations

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