I am writing JavaScript to simulate myself clicking through links on a web page. I need to check if page is fully loaded after a link is clicked, before clicking on another link.
In short, I need to do something like this:
if(page is fully loaded) {
//someInputBoxs.value='something'
//submitButton.click() //will redirect to another page}
if(page2 is fully loaded) {
//link2.click(); }
if(page3 is fully loaded) {
//link3.click(); }
The reason to check if the page is fully loaded every time, is to avoid clicking on undefined DOM elements.
To check page load status, most of online resource suggest using window.onload
, but then it can only check load state for once.