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

103
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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