通过casperjs文档我无法找到从客户端javascript中看到console.log的位置。这可能吗?
答案 0 :(得分:44)
我不太确定完全理解您的问题,但您可以执行以下操作:
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