I've found what was causing me this problem since posting this question, so I will share the answer below, in case anyone else encounters a similar problem:
In the standard quickstart example on the SpookyJS Github page, there's a commented-out 'console' event listener in Spooky which, when uncommented, will cause all output from Casper to appear on the screen:
// Uncomment this block to see all of the things Casper has to say.
// There are a lot.
// He has opinions.
spooky.on('console', function (line) {
console.log(line);
});
When this event listener is set, it will log all output from Casper to the screen. The examples I was trying to log to the console in my question were all being run inside calls that Spooky was passing to Casper to process, so that's why I was not seeing them displayed. With this event listener set, my output appears, as well as the output used by the __utils__.echo
function call in xShirase's answer.
Additionally, Casper provides an echo
function which can be used to send output outside of Casper's evaluate function, which, by default, only has access to the scope of the page being viewed:
spooky.then(function () {
this.echo("foo");
});
Since the standard configuration sets Casper's logging level to debug
and sets verbose logging on, a lot of information will be displayed once this event listener is set. This can be avoided by setting the logging level to error
or some other logging level supported by Casper.