Skip to content

Instantly share code, notes, and snippets.

@lazywithclass
Created May 23, 2012 12:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lazywithclass/2775023 to your computer and use it in GitHub Desktop.
Save lazywithclass/2775023 to your computer and use it in GitHub Desktop.
working with casperjs and http status codes
var casper = require('casper').create({
httpStatusHandlers: {
404: function(self, resource) {
self.echo(resource.url + ' not found (404)');
},
500: function(self, resource) {
self.echo(resource.url + ' gave an error (500)');
}
},
verbose: true
});
casper.start('http://mywebsite/404', function() {
this.echo(this.result.status);
this.echo(this.currentHTTPStatus);
this.echo('We suppose this url return an HTTP 404');
});
casper.run(function() {
this.echo('Done.').exit();
});
@gabegomez014
Copy link

I know you made this 5 years ago, but I am currently using this for a project I am working on and this example was key in helping me understand how to use it. So with that being said, I can't stress a big enough THANK YOU!!!!!! Greatly appreciated 5 years down the road by at least one person

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment