Created
May 23, 2012 12:33
-
-
Save lazywithclass/2775023 to your computer and use it in GitHub Desktop.
working with casperjs and http status codes
This file contains 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 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(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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