Wait for text to appear when using Puppeteer

前端 未结 5 2055
星月不相逢
星月不相逢 2020-12-16 13:54

I wonder if there\'s a similar way as in Selenium to wait for text to appear for a particular element. I\'ve tried something like this, but it doesn\'t seem to wait:

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-16 14:09

    You can use waitForFunction. See https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagewaitforfunctionpagefunction-options-args

    Including @elena's solution for completeness of the answer:

    await page.waitForFunction('document.querySelector(".count").inner‌​Text.length == 7');
    

提交回复
热议问题