OnetapInc / chromy

Chromy is a library for operating headless chrome. 🍺🍺🍺
MIT License
605 stars 41 forks source link

querySelectorAll returning an empty object #108

Closed pedrro closed 6 years ago

pedrro commented 6 years ago

I'm using Chromy framework to scrap a page, so, this is the html:

<ul class="a">
<li class="b"><h2>text here</h2></li>
<li class="b"><h2>text here</h2></li>
<li class="b"><h2>text here</h2></li>
<li class="b"><h2>text here</h2></li>
</ul>

So, if I do on chrome console the selection like this:

document.querySelectorAll('.b')

It will return me a nodeList with 4 objects inside and that's right, but if I do the same selection inside chromy script it return an empty object with 4 empty objects { '0': {},'1': {},'2': {},'3': {}}.

Can you please help me to figure out why this is happening?

That's my Chromy script

chromy.chain()
  .goto('https://localhost:8080/')
  .evaluate(() => {
    return document.querySelectorAll('.b');
  })
  .result((r) => console.log(r))
  .end()
  .then(() => chromy.close());