Scenario: selenium, java, firefox and alerts So, I wrote some time back code to deal with an alert while crawling websites.
This sort of code is easily found when searching for selenium and alerts ..
try {
Alert alert = driver.switchTo().alert();
alert.accept();
} catch (NoAlertPresentException e) {
LOGGER.debug("No alert available: " + url);
}
This seemed to work for the a couple test cases I had. One is the tomcat home page, on it you get a popup if you click 'status' for example.
Now I bumped into a dialog that blocks the above code. the switchTo() returns a TargetLocator but alert() on that locator blocks and never returns.
The links that triggers that dialog is http://www.fcb.com/news/rss.
Also, on this post I found a comment saying "we can't get a handle on confirmation boxes that are created on the onload functions" I wonder what that means but my reputation is so low I can't comment yet :).
Also, as pointed out in the first answer, both the problematic dialog and the one that works are "authentication" alerts. I don't want to authenticate.
So, to recap, the ask is why does the TargetLocator.alert() call block? My ultimate goal is to close any such dialog I may encounter after driver.get(url).
Any thoughts?
Thanks Cristian
p.s. regarding the duplicate tag, I don't think it's a duplicate. The code suggested there does not work either. One of the main objectives for my question is to understand why this popup blocks on the call to alert()