使用casper / phantomjs输出客户端控制台 [英] Output client-side console with casper/phantomjs
本文介绍了使用casper / phantomjs输出客户端控制台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
浏览casperjs文档我找不到从客户端javascript可以看到的console.log。这是可能吗?
Going through the casperjs documentation I couldn't find where I could see the console.log from client-side javascript. Is this possible?
推荐答案
我不太确定完全了解你的问题,但你可以做如下:
I'm not really sure to fully understand your question, but you can do something like the following:
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
这篇关于使用casper / phantomjs输出客户端控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文