I'm trying to get the data inside of every page from a list and would like help to iterate through all the elements with Puppeteer.
I'm accessing an element with the following code:
await page.waitForSelector('#element')
.then(() => console.log("got it"))
.catch(e => {
console.log("Error: " + e);
});
This #element is populated with a span that has around 20 div (child) with a clsas of .li like below:
<div id="element">
<div id="other">
</div>
<span id="listofitemstoclick">
<div class="li">
</div>
<div class="li">
</div>
<div class="li">
</div>
...
</span>
</div>
I need to click on the first, go back, click on the second, and so on.
Any approach that would be good here?
As the .li doesn't have any href, I believe I need to get each child and click one by one, but yet couldn't find any good way to retrieve each child, click, go back and click on the next.
Appreciate the help!