Search code examples
node.jsxpathpuppeteer

How do I check if certain text exists on a page (puppeteer)


Sorry in advance if I seem kinda clueless, I just started using puppeteer yesterday and I’m inexperienced with this kinda stuff. I’m trying to check if a certain page (opened with puppeteer) has the phrase “hello” for example, keep in mind that I know the XPath of the text (if it exists). I’ve tried .waitForXPath() but I can’t seem to get it to work. Is there an easier function for this?


Solution

  • (await page.content()).match('hello')