I have read the newest puppeteer v22.x documentation about XPath, still don’t know how to use the XPath in puppeteer 22.x.
the goal is I want to click a text contain ‘Next’ text, here the HTML that ‘Next’ button
<div class="bla bla bla" role="button" tabindex="0">Next</div>
Here the behavior that i’ve analyzed,
- the class value is not static, it will randomly generated every request or page refreshed,
- i can’t use the
role="button"
as the indicator for the button, because in that page there are many tag usingrole="button"
in their attribute
Here some sample i’ve tried,
await page.waitForSelector("xpath/div[@role='button' and text()='Next']");
await page.waitForSelector("//div[@role='button' and text()='Next']");
Thanks,