Use dynamic selector with Puppeteer to click different divs in a loop

Viewed 25

I am using Puppeteer to automate an application. There is a feed with multiple divs in it. I am able to select the correct div inside a loop with the following "querySelector" by incrementing a counter.

let form = document.documentElement.querySelectorAll("div[role=feed]").item(0).childNodes[current + 1].querySelector("form")

With Puppeteer I would like to click the div. How can I click the selector above with Puppeteer? Like:

await page.click(selector)
0 Answers
Related