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

后端 未结 4 676
Happy的楠姐
Happy的楠姐 2020-12-01 10:16

Why when I use console.log in evaluate, it works:

casper.then(function() {
  this.evaluate( function() {
    console.log(\'hello\')         


        
4条回答
  •  既然无缘
    2020-12-01 11:14

    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);
    });
    

提交回复
热议问题