Going through the casperjs documentation I couldn't find where I could see the console.log from client-side javascript. Is this possible?
Asked
Active
Viewed 1.1k times
1 Answers
44
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();
Output:
$ casperjs log.js
from the browser, I can tell you there are 4 entries

NiKo
- 11,215
- 6
- 46
- 56
-
For me, I don't see 'from the browser' – Abhik Bose Pramanik Jun 01 '12 at 17:24
-
1It works for me when I use `this.echo`, I've edited your answer. – jgillich Jun 25 '14 at 09:05
-
old answer, but to see something like `from the browser`, just add that int the `this.message` part of the function... like `this.echo("from the browser, " + message);` – Jeff Dec 28 '15 at 20:47