0

Background / use case

I would like to automate some page interactions by pasting a script into my browser console (normally Chrome/Chromium or in my case IE11 because.. don't ask.)

Typical steps in one iteration:

  • (initial) Visit a page, wait until it is fully loaded.
  • Fill in form values automatically, trigger some buttons, submit.
  • Wait for new page after form submission.
  • Go to 'next page', wait until it is fully loaded, start over with a new set of form values.

The "Visit a page" or "Go to 'next page'" could either happen by clicking a button, or by setting document.location.href explicitly.

The "wait for ..." can take up to 30 seconds in both cases. Not for any good reason, just because.

I am aware (to my current understanding) that the js (event listeners etc) included in a page does not survive a new page load. I am specifically asking about js called form the browser's developer console.

Question

How can I register an event listener from the console for "page load complete" after setting document.location.href, or doing something equivalent?

As mentioned, in my use case I would need to do this with Internet Explorer 11. But I assume people are more familiar with the developer tools in Chromium or Firefox. Any answer that works in one of these browsers is welcome, just mention which browser you tried this with.

Limitations

  • I do not control the web application where I want to do this, I only control my browser. It also does not look like the developers of said application would be likely to respond to feature requests or wishes.
  • Perhaps someone will suggest to do this with an iframe. I am not sure this will work. If it does, this would be a different question.
  • Perhaps someone will suggest some kind of browser simulator tool to use instead of the console. Unfortunately I need/want to make this work on Internet Explorer in a corporate Windows environment with limited privileges. Alternative tools can be mentioned, but there is a reason why I focus on browser console.
donquixote
  • 4,877
  • 3
  • 31
  • 54
  • Why was this downvoted? I tried to be as detailed as possible. – donquixote Jun 23 '19 at 12:59
  • The Dev console is cleared if the page it's connected to is reloaded, including any extra code you have added via the console, there is no way around that. – Einar Ólafsson Jun 23 '19 at 13:43
  • If using a (headless) browser automation tool is out of the question, maybe you can experiment with a browser extension which should have the necessary permissions and cross-page runtime. – Bergi Jun 23 '19 at 14:36
  • @EinarÓlafsson It is not fully reset. E.g. I found that functions I defined in the console were still there, and also setInterval was still running. – donquixote Jun 25 '19 at 13:56

0 Answers0