Reputation: 91
var casper = require('casper').create({
//verbose: true,
logLevel: "debug",
waitTimeout: 20000,
onError: function(self, m) {
console.log('FATAL');
self.exit();
}
});
When I execute my code in the command line it will print a CasperError. For example:
CasperError: Cannot dispatch mousedown event on nonexistent selector: #selector; or CasperError: No element matching selector found: #selector
I would expect it to instead be outputting the text 'FATAL'. I've tried casper.Echo() instead of console.log() and the message is still not displayed.
I have also set:
casper.on('remote.message', function(message) {
this.echo(message);
});
And elsewhere in the script console.log() will output text tothe command line.
So it would appear to me that this onError function is not being called at all. Any idea why this might be?
Upvotes: 2
Views: 1187
Reputation: 166
https://stackoverflow.com/a/20481404/4977318 - this answer helped me.
So, in your case it will be:
casper.on('error', function(msg,backtrace) {
console.log('FATAL');
this.exit();
});
Upvotes: 3