Jacopo Jazzetta
Jacopo Jazzetta

Reputation: 11

Click on a button with specific text in puppeteer

hello I need a method to click with puppeteer on a button that has an identical class to others but different text inside the problem is that this text is identical to others on the page so in short I need a way to click on a button with a text below a specific class. is there any way? I hope I have explained, thanks

my code at the moment :

await page.click ("._0xLoFW.FCIprz")

html :

<div class="_0xLoFW FCIprz"><span class="_7Cm1F9 ka2E9k uMhVZi dgII7d z-oVg8 pVrzNP">40</span></div>

Upvotes: 1

Views: 991

Answers (1)

vsemozhebuty
vsemozhebuty

Reputation: 13782

You can try XPath:

const [element] = await $x("//div[@class='_0xLoFW FCIprz'][.='40']");
await element.click();

Upvotes: 1

Related Questions