Casperjs inspect a javascript Object

Charles picture Charles · Jun 17, 2012 · Viewed 7k times · Source

How can I inspect an object in a casperjs script ?

I tried console.log(arguments) but it only prints [object Arguments] or [object Object].

I would like to expect something like: { 'firstparam': 'value' ... }

Like in the Javascript console or in Node.js...

Maybe it's a Phantomjs question, I'm not sure...

Answer

Charles picture Charles · Jun 17, 2012

I think I found it: http://docs.casperjs.org/en/latest/debugging.html#dump-serialized-values-to-the-console

var utils = require('utils');

utils.dump({
    foo: {
        bar: 42
    },
});