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

128
Vistas
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 Respuestas
Responde la pregunta

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 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