OnetapInc / chromy

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

Wait(selector) times out #73

Closed jonahlau closed 6 years ago

jonahlau commented 6 years ago

I have the following code that's supposed to setFile on a file input. After uploading, the FB UI will append a new div ( class '._3-98._3-8-') to the DOM.

I was expecting wait(selector) to be able to wait until the new div appears and then evaluate the result, but it stays waiting forever and then times out. I can confirm that this div appears if i do wait(10000) instead, but its more reliable to wait until the element appears!

Please help! Thanks!!

chromy
  .chain()
  .goto('https://www.facebook.com/ads/tools/text_overlay')
  .setFile('input[type="file"]', __fileName)
  .wait('._3-98._3-8-')
  .evaluate(() => {
      //do something
  })
  .end()
  .then(() => chromy.close());
dotneet commented 6 years ago

Hi @jonahlau,

the input element you want to set a file seems to be added dynamically. so I think you need to insert .wait('input[type="file"') before .setFile().

jonahlau commented 6 years ago

Yes you are absolutely right! Thank you!