PhantomJS >= 1.6 must be installed on your system (1.7 recommended). Check out PhantomJS' installation instructions, and:
Ensure to always install the latest stable version of PhantomJS;
Ubuntu users Double check the version of PhantomJS provided by your apt repository, if any. Often, only old versions are provided.
OSX users If you use Homebrew, you can install both CasperJS and PhantomJS using this command:
$ brew install casperjs
Installation can be achieved using git:
$ git clone git://github.com/n1k0/casperjs.git
$ cd casperjs
$ git checkout tags/1.0.0-RC2
$ 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.7
$ casperjs --version
1.0.0-RC2
You are now ready to write your first script!
Note
The casperjs
executable is written in Python, so please ensure
that a Python interpreter is available on your platform.
Ruby version
Added in 1.0
A Ruby version of the casperjs
executable is also
available in the bin/
directory; in order to use the 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.0.0-RC2 at /Users/niko/Sites/casperjs, using PhantomJS version 1.6.0
...
Help! I don't have Python nor Ruby (Hi, Windows user)
If you're on Windows, this is the way you may manage to get casper working the most easily:
phantom.casperPath = 'C:\\path\\to\\your\\repo\\lib\\casperjs-1.0.0-RC2';
phantom.injectJs(phantom.casperPath + '\\bin\\bootstrap.js');
var casper = require('casper').create();
// do stuff
Then just run your script using the phantom.exe
program.
Note There is no output coloration when running CasperJS on Microsoft platforms.
Contribute!
Feel free to play with the code and report any issue on github. CasperJS has also its own on twitter account.