Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

99
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!