1

I am using puppeteer for a webcrawler of mine. Sometimes it needs to click gui elements that take time to show up.

It has been bugging me that for every click() I call I also need to call a timeout manually. I wondered if it is possible to decorate all the click functions somehow.

As puppeteer is a library I do not instantiate any of these myself, rather they're given from functions such as Page.$(selector) the click() is available in multiple classes and all of them will need to have it applied.

What's a good pattern to solve this?

karel
  • 5,489
  • 46
  • 45
  • 50
Yorai Levi
  • 473
  • 5
  • 17
  • [Does this answer your question?](https://stackoverflow.com/questions/46135853/puppeteer-wait-an-element-is-visible) – Matt Oestreich Jan 11 '20 at 19:12
  • Partially, I still use the timeout because there is animation that takes time to complete – Yorai Levi Jan 11 '20 at 19:20
  • It shouldn't matter if there is an animation, though.. That method should wait until a specific element is available, regardless why it needs to wait. – Matt Oestreich Jan 11 '20 at 19:32

0 Answers0