Print array elements to virtual terminal

26 views
Skip to first unread message

Luis P. Mendes

unread,
Aug 14, 2015, 12:10:10 PM8/14/15
to CasperJS
How to print each link to the console?

Tried:

casper.then(function() {
    // aggregate results for the 'casperjs' search
    links = this.evaluate(getLinks);
    links.forEach(function (element) {
        console.log(element);
        console.log(this.value);
    }, this);
});

But get nothing in return.

When using 'echo', like   echo(element);
get an error:
TypeError: 'undefined' is not a function (evaluating 'this.echo(element)')

How to do this?

Luis P. Mendes

unread,
Aug 14, 2015, 3:03:56 PM8/14/15
to CasperJS

Basically, what I need is a way to print the contents of some variables in order to follow/debug their contents.

Alex peguero-cruz

unread,
Oct 30, 2015, 4:07:44 AM10/30/15
to CasperJS
var element = this.getElementInfo('some element');

//to see what the out put is in order to loop through it. 
utils.dump(element);
var array = [];
var i =0;

for (; i < length; i++) {
    var obj = {};
   
    array.push(obj.name[i].attribute)
                   or
    array.push(obj.name[i].tag)
   array.push(obj.name[i].href)
   
}

utils.dump(array)
Reply all
Reply to author
Forward
0 new messages