1

I am using puppeteer to automate form filling process.I have written a code in which i have used page.waitFor function each time when it needs time to load whether it's page or form element.

Suppose i put a wait like waitFor(10000) to load that element.Usually it takes less than that but if internet is slow then it might take more than that. So in this case it fails.

Just like this i put lots of waitFor() in my code at each step and anyone of them can fails at any point.

I want something like which waits until the page and that specific element loads completely and i don't need to use and be worried for any of that wait method.

I am a new to this , so help is much appreciated.Thanks.

Bats
  • 47
  • 4

1 Answers1

0

Best practice is to wait for the presence of a selector instead: page.waitForSelector('#someId')

Alternative you can also use page.waitFor('#someId')

Waiting for a set time should be prevented if possible.

Simon Thiel
  • 2,888
  • 6
  • 24
  • 46
  • This solution helped me. I also thought that this would be it , but as a newcomer i wasn't sure. Thanks a lot Simon. Appreciate that. – Bats May 13 '19 at 06:59