CasperJS can be installed on Mac OSX, Windows and most Linuxes.
- PhantomJS 1.9.1 or greater. Please read the installation instructions for PhantomJS
- Python 2.6 or greater for
New in version 1.1.
- Experimental: as of 1.1.0-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). The SlimerJS developers documented the PhantomJS API compatibility of SlimerJS as well as the differences between PhantomJS and SlimerJS. Note that it is known that coffescript support breaks as of SlimerJS 0.9.6; we are investigating that issue.
New in version 1.1.0-beta4.
Versions before 1.1.0-beta4 that were installed through npm required an unspecific PhantomJS version by means of an npm dependency. This led to lots of confusion and issues against CasperJS not working properly if installed through npm. Starting with 1.1.0 the installation of an engine (PhantomJS, SlimerJS) will be a real prerequisite, regardless of the installation method you choose for CasperJS.
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
$ brew upgrade casperjs
Upgrade only update to the latest release branch (1.0.x|1.1.0-dev).
Installing from npm¶
New in version 1.1.0-beta3.
You can install CasperJS using npm:
For most users (current version 1.1.0-beta4):
$ npm install -g casperjs
If you want a specific older version:
If you want to install the current master from git using npm:
$ npm install -g git+https://github.com/casperjs/casperjs.git
-g flag makes the
casperjs executable available system-wide.
While CasperJS is installable via npm, it is not a NodeJS module and will not work with NodeJS out of the box. You cannot load casper by using require(‘casperjs’) in node. Note that CasperJS is not capable of using a vast majority of NodeJS modules out there. Experiment and use your best judgement.
Installing from git¶
From the master branch¶
$ git clone git://github.com/casperjs/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-beta4 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 at /Users/niko/Sites/casperjs, using slimerjs version 0.8.0
You are now ready to write your first script!
Installing from an archive¶
You can download tagged archives of CasperJS code:
Latest development version (master branch):
- https://github.com/casperjs/casperjs/zipball/master (zip)
- https://github.com/casperjs/casperjs/tarball/master (tar.gz)
Latest stable version:
- https://github.com/casperjs/casperjs/zipball/1.1.0 (zip)
- https://github.com/casperjs/casperjs/tarball/1.1.0 (tar.gz)
Operations are then the same as with a git checkout.
CasperJS on Windows¶
Phantomjs installation additions¶
- Modify this path appropriately if you installed PhantomJS to a different location.
Casperjs installation additions¶
New in version 1.1.0-beta3.
PATHenvironment variable (for versions before 1.1.0-beta3 append
- 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