Skip to content

Instantly share code, notes, and snippets.

@rnagle
Created October 31, 2012 21:46
Show Gist options
  • Save rnagle/3990130 to your computer and use it in GitHub Desktop.
Save rnagle/3990130 to your computer and use it in GitHub Desktop.
Experiment with Casper.js
var clients = Array(10),
url = 'http://localhost:5000/';
var on = function(resource) {
if (resource.url.match('data.json'))
this.echo("[update] Received: " + resource.url, 'INFO');
};
var start = function() {
if (this.resourceExists('data.json')) {
this.echo('Loaded data.json', 'INFO');
} else {
this.echo('Failed to load data.json', 'ERROR');
}
};
var then = function() {
this.echo("Loaded " + url, 'INFO_BAR');
};
for (var i = 0; i < clients.length; i++ ) {
clients[i] = new require('casper').Casper({
verbose: true,
logLevel: "debug"
});
clients[i].on('resource.received', on);
clients[i].start(url, start);
clients[i].then(then);
clients[i].wait(60000);
clients[i].run();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment