Created
October 31, 2012 21:46
-
-
Save rnagle/3990130 to your computer and use it in GitHub Desktop.
Experiment with Casper.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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