console.log doesn’t work in CasperJS’ evaluate with setTimeout

Because you’re mixing up casperjs and remote page environments. The evaluate function will execute code within the remote page env, so the console.log call won’t output anything.

If you want to catch remote console.log calls, listen to the remote.message event:

casper.on('remote.message', function(msg) {
    this.echo('remote message caught: ' + msg);
})

Btw, documentation for events is pretty much exhaustive, as well as the one for evaluate.

Leave a Comment