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

124
Visualizações
JavaScript wait for click

I have x - pages of lists of 15 objects each. I would like to go through all the pages downloading the text of each of the 15 items in the list. The download works, but the same elements are written to the variable "a" (probably because the code executes faster than clicking from within the code). Is it possible to put it to sleep / wait for execution and then go to the next page?

var a = '';
for (let i = 0; i < 999; i++) {
    const paragraphs = document.querySelectorAll(".my-object-on-list");
    paragraphs.forEach(p => a = a + p.outerText);
    angular.element(document.getElementsByClassName('btn-forward')).click();
    setTimeout(1);//sleep for 1s?
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

There are many problems in your script

Try this

const paragraphs = document.querySelectorAll(".my-object-on-list");
cons ctn = 0;
const btn = document.getElementsByClassName('btn-forward')
let a = []
const run() {
  if (cnt >= paragraphs.length) {
    processResults();
    return 
  }
  a.push(p.outerText);
  angular.element(btn).click();
  cnt++
  setTimeout(run,3000);
}
run()

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