1

I'm trying to convert a nodeList into an array and return it from the evaluate() function but get NULL instead of an array. What I'm doing wrong?

casper.wait(5000, function() {
  test.assertExists('ul.jobs-search-results__list', "Element is found");  //this test is OK
  var listItems = this.evaluate(function() {
    var nodes = document.getElementsByClassName('jobs-search-results__list').childNodes;
    nodes = Array.prototype.slice.call(nodes);
    return nodes;
  });
  console.log('listItems: ' + listItems);  //null returned
});
P.S.
  • 15,970
  • 14
  • 62
  • 86
Alex Mac
  • 11
  • 2
  • if `this.evaluate` calls the callback asynchronously, then you probably need to read https://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call – Jaromanda X Aug 01 '17 at 11:31

0 Answers0