Puppeteer click also on the second and third items that have the same class

Viewed 424

I'm trying to use puppeteer for click on 3 div, but they have the same class.

page.click('.not-selected-1Tb33').then(async () => {
    await page.click('.list-item-MOAq4')
})

Puppeteer clicks on the first that it find, but I want to click also on the second and the third that have the same class name.
How I can do?
Thanks in advance and sorry for bad english!

1 Answers

Use for ... of:

const buttons = await page.$$(selector)
for (let btn of buttons) {
   await btn.click()
}
Related