Skip to main content

Wait until redirect and grab redirect url

Essentially, I have a function that will input my email into the input text field and click the next button to redirect onto the next page.

However, I wanted to wait until the re-direct is complete i.e. the dom content has fully loaded, and then return the current url. I have attempted the following - however, it keeps me under an infinite loop, for example:

(function() {const setValue = Object.getOwnPropertyDescriptor(
window.HTMLInputElement.prototype,
"value").set;
const modifyInput = (name, value) => {
const input = document.getElementsByName(name)[0]
setValue.call(input, value)
input.dispatchEvent(new Event('input', { bubbles: true}))
};
modifyInput('email', "incorrect@email.com");
document.querySelector("#submitBtn").click();
while(true){
    if(window.location.href.includes('https://okta.com/login/login.htm')){
        console.log(window.location.href);
        break;
    }else{
        continue;
    }
}
}())

I am using the following url:

https://ift.tt/mHzw37n

Via Active questions tagged javascript - Stack Overflow https://ift.tt/6HiEc4R

Comments