Charles
Charles

Reputation: 11796

Casperjs inspect a javascript Object

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...

Upvotes: 16

Views: 7044

Answers (2)

klidifia
klidifia

Reputation: 1495

JSON.stringify for a simple string read, e.g.

casper.test.comment(JSON.stringify(object));

Upvotes: 1

Charles
Charles

Reputation: 11796

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
    },
});

Upvotes: 16

Related Questions