Why when I use console.log in evaluate, it works:
casper.then(function() {
this.evaluate( function() {
console.log('hello');
});
});
But this doesn’t work:
casper.then(function() {
this.evaluate( function() {
setTimeout( function() {console.log('hello');}, 1000);
});
});
Because you’re mixing up casperjs and remote page environments. The
evaluatefunction will execute code within the remote page env, so theconsole.logcall won’t output anything.If you want to catch remote
console.logcalls, listen to theremote.messageevent:Btw, documentation for events is pretty much exhaustive, as well as the one for evaluate.