Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 674
Charles Avatar asked Jun 16 '12 23:06

Charles


People also ask

Where is JavaScript in inspect?

There's a powerful tool hiding in your browser: Inspect Element. Right-click on any webpage, click Inspect, and you'll see the innards of that site: its source code, the images and CSS that form its design, the fonts and icons it uses, the Javascript code that powers animations, and more.


2 Answers

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
    },
});
like image 103
Charles Avatar answered Sep 26 '22 23:09

Charles


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

casper.test.comment(JSON.stringify(object));
like image 38
klidifia Avatar answered Sep 26 '22 23:09

klidifia