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

316
Visualizações
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 à 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