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

100
Vistas
Puppeteer wait for lists coming up

The site i am working on have a button.

when i click the button using puppeteer it makes 10 more lists on ul element.

At first time the site have already 10 lists on the ul element and whenever click the button 10 more lists added to the ul.

So here is the question

How do i wait for 10 more lists coming up on ul element after click the button using puppeteer ?

ex)

first state

<ul>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>

i want catch this moment after click the button

<ul>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>

I have tried below methods also but it's not working.

 await Promise.all([
        page.click('button#fetch-next-page'),
        page.waitFor('*'),
        // page.waitForSelector('div.loop-item', { hidden: true }),
      ])
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

 await Promise.all([
        page.click('button#fetch-next-page'),
        page.waitForFunction(
          prevLength => {
            const curLength = document.querySelectorAll('div.loop-item').length
            console.log(curLength)
            return curLength !== prevLength
          },
          {},
          prevLength,
        ),
      ])

keep previous lists length and pass it to page.waitForFunction's parameter works as i expected

Thanks a lot @ggorlen

about 4 years ago · Juan Pablo Isaza Denunciar
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