Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

241
Visualizações
Iterate through all elements on a div and click on each on Puppeteer

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!

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda