When using my web application, a JavaScript message pops up asking 'Are you sure you want to navigate away from this page?' when attempting to open a new page. I am aware that I can handle this message with the Selenium.getAlert()
method (or some variation of it, which I have yet to test).
However, my dilemma lies in the fact that this message only appears when trying to leave the current page. In Selenium, I typically navigate to a new page using Selenium.open("new address")
or go back using Selenium.back()
. The issue arises when I try to interact with the alert before the page finishes loading.
This poses a problem as the Selenium.open
method does not proceed to the next line of code until the new page is fully loaded. But, the page cannot load unless the program moves on to the next line of code and handles the alert message. It creates a blocked scenario for me, and I am unsure how to resolve it.