CasperJS Navigation scripting & testing for PhantomJS and SlimerJS

Install PhantomJS or SlimerJS, then:

npm install casperjs
node_modules/casperjs/bin/casperjs selftest
Other install options
5,815 Stargazers 926 Forks


CasperJS comes with a basic testing suite that allows you to run full featured tests without the overhead of a full browser. Output the tests to xunit for long term code health as well.

casper.test.begin('Hello, Test!', 1, function(test) {

$ casperjs test sample-test.js
Test file: sample-test.js
# Hello, Test!
PASS Subject is strictly true
PASS 1 test executed in 0.023s, 1 passed, 0 failed, 0 dubious, 0 skipped.


Capture data from web pages simply that don't contain APIs. Validate your production environment on a regular basis. Alternatively, use this to load your application with data.

var casper = require('casper').create();
var links;

function getLinks() {
// Scrape the links from top-right nav of the website
    var links = document.querySelectorAll('ul.navigation li a');
    return, function (e) {
        return e.getAttribute('href')

// Opens casperjs homepage

casper.then(function () {
    links = this.evaluate(getLinks);
}); () {
    for(var i in links) {

$ casperjs query-casperjs.js!forum/casperjs

Support Development