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

325
Vistas
How to execute the command after each javascript statement in a block?

I want to remove some connection from a Social Media account using JavaScript. If I execute the statements line by line, it works perfectly, but when I execute them in a block of code, it doesn't work.

THE BLOCK CODE

function sleep(delay) {
    var start = new Date().getTime();
    while (new Date().getTime() < start + delay);
}


for(var i=0;i<5;i++) {
    //Click on connection
    sleep(1000);
    document.getElementsByClassName('reusable-search__entity-result-list list-style-none')[0].getElementsByClassName('entity-result__title-text t-16')[1].getElementsByClassName('app-aware-link')[0].click();
    sleep(1000);
    //Remove connection button
    document.getElementsByClassName('ivm-view-attr__img--centered EntityPhoto-circle-3 lazy-image ember-view')[1].click();
    sleep(1000);
    document.getElementsByClassName('artdeco-dropdown__content-inner')[0].getElementsByTagName('li')[6].getElementsByClassName('pvs-profile-actions__action display-flex align-items-center artdeco-dropdown__item artdeco-dropdown__item--is-dropdown ember-view')[0].click();
    //Back
    sleep(1000);
    history.back();
}

I get every time the following error: TypeError: undefined is not an object (evaluating 'document.getElementsByClassName('artdeco-dropdown__content-inner')[0].getElementsByTagName')

It seems that after Click on connection part, the page is not loading, and it does only after the block is done. (I tried also without for loop, only those statements, but it happened the same like in the loop).

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