Why when I use console.log
in evaluate
, it works:
casper.then(function() {
this.evaluate( function() {
console.log(\'hello\')
Building on @odigity's answer, this makes casperjs die with a more familiar error/stacktrace:
var util = require('util');
casper.on('page.error', function exitWithError(msg, stack) {
stack = stack.reduce(function (accum, frame) {
return accum + util.format('\tat %s (%s:%d)\n',
frame.function || '',
frame.file,
frame.line
);
}, '');
this.die(['Client-side error', msg, stack].join('\n'), 1);
});