带有 casper/phantomjs 的输出客户端控制台



浏览 casperjs 文档时,我找不到在哪里可以看到控制台.log从客户端 javascript 中。这可能吗?

我不太确定是否完全理解您的问题,但您可以执行以下操作:

var casper = require('casper').create({
    logLevel: "debug"
});
casper.on('remote.message', function(message) {
    this.echo(message);
});
casper.start('http://google.com/', function() {
    this.evaluate(function sendLog(log) {
        // you can access the log from page DOM
        console.log('from the browser, I can tell you there are ' + log.length + ' entries in the log');
    }, this.result.log);
});
casper.run();

输出:

$ casperjs log.js 
from the browser, I can tell you there are 4 entries

最新更新