I'm using casper.evaluate() to get an array of data from within the page. However it seems to fail to return an array (whereas returning strings work flawlessly). What might be the issue?
For clarification: the code in evaluate is:
function(){
return $('#id a').map(function(i, e) {
return $(e).attr('href');
}).get();
}
The .get() at the end of the call is meant to get an array instead of a jQuery object. BTW, I'm sure jQuery is available in the page.
You dont need jQuery here:
casper.evaluate(function() {
return [].map.call(__utils__.findAll('#id a'), function(node) {
return node.getAttribute('href');
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With