Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

250
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda