phantom not working with google search

44 views
Skip to first unread message

PL bader

unread,
Jul 4, 2020, 3:19:07 PM7/4/20
to phantomjs

TypeError: undefined is not an object (evaluating 'document.getElementsByClassName('my-class-name-of-the-element').innerText')


am on search page example :

  page.open(myurl).then(function(status) {
  console.log('page is loading');
  
name = page.evaluate(function () {
      
  //get name
return a = document.getElementsByClassName('LC20lb DKV0Md')[0].innerText

});

name.then(function(aswan) {
console.log('got name');
console.log(aswan);
 info.username=aswan;
 console.log(info.username);
res.send(info.username);
  ph.exit();

});
});


am not getting the innerText of the element and am getting null
Reply all
Reply to author
Forward
0 new messages