.. index:: Installation
CasperJS can be installed on most Linuxes, OSX and Windows.
.. index:: PhantomJS, Python
Note
.. versionadded:: 1.0
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
...
.. index:: Homebrew
Installation of both PhantomJS and CasperJS can be achieved through Homebrew:
$ brew install casperjs
.. index:: git
Installation can be achieved using git. The code is mainly hosted on Github.
$ 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.7
$ casperjs --version
1.0
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>`!
You can download tagged archives of CasperJS code:
Latest stable version:
- https://github.com/n1k0/casperjs/zipball/1.0.0 (zip)
- https://github.com/n1k0/casperjs/tarball/1.0.0 (tar.gz)
Latest development version (master branch):
- https://github.com/n1k0/casperjs/zipball/master (zip)
- https://github.com/n1k0/casperjs/tarball/master (tar.gz)
Operations are then the same as with a git checkout.
.. index:: Windows
- Append
";C:\phantomjs"
to yourPATH
environment variable. - Modify this path appropriately if you installed PhantomJS to a different location.
.. versionadded:: 1.0
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 yourPATH
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
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.
.. index:: Bugs, REPL
- Due to its asynchronous nature, CasperJS doesn't work well with PhantomJS' REPL.