Wait for text to appear when using Puppeteer

前端 未结 5 2038
星月不相逢
星月不相逢 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:17

    The best solution you can do using waitForFunction() (avoid weird function as string):

    const selector = '.count';
    await page.waitForFunction(
        selector => document.querySelector(selector).value.length > 0,
        {},
        selector
    );
    

    Depends of the type of the text, replace value by innerText.

    Check puppeteer API

提交回复
热议问题