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

114
Visualizações
Javascript snippet in dev tools seems to not execute after a web page changes url

I'm very new to JavaScript and trying to automate a small test process in a browser (Sources - Snippets) with JavaScript, and it spans over several web pages, and I noticed that after a page reloads or a new page loads the subsequent code seems to not execute. Even if I set a big timeout. The code lines executed separately in the "console" tab of the dev tools work fine. So the question is: what shall I do to make them execute one after another in one snippet?

Here is just one step after which nothing seems to happen:

(function() {
  //Link   
  document.querySelector("#main-content > p:nth-child(6) > a").click(); // a click works, but the next line does not do anything even with a big timeout.

  //LOGIN FORM
  //User name
  setTimeout(() => {
    document.querySelector("form input[formcontrolname='benutzername']").value = 'xxxx'
  }, 3000); //when executed separately in the console, it works.
})()
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Got an answer from an expert: "When automating from the console, the code won't survive a page reload because the code is running in the document process, so when it changes the code is gone."

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