Webdriver hangs in new window with "about:blank" in address bar,
transitioning to file download dialog
I need some help for the following issue with Webdriver, Java, and Firefox.
In my testing, when clicking on a link, 1) it will often open a new window
with a normal web page.
2) occasionally, it will open a new window with "about:blank" in address
bar (see attached Picture 1); after 20 to 60 seconds the new window will
disappear and a file download window will appear (see attached Picture 2).
Because the URL is rewritten for SEO, there is no way to check the URL
before or after clicking on it to determine whether the link connects to a
normal web page or a downloadable file.
In both cases, driver.getWindowHandles().size() == 2 so switch to the new
window successfully using the following statements in order to check
whether a certain WebElement exists in new window. for (String winHandle :
driver.getWindowHandles()) { driver.switchTo().window(winHandle); }
But if the link connects to a downloadable file, the execution will hang
for any of the following methods; getWindowHandles() always returns 2
while new window with "about:blank" in address bar presents before it is
replaced by the file download dialog. It occasionally throws a
NoSuchWindowException exception; but most of the time, it just hangs. I
tried the Explicit and Implicit Waits to no avail.
findElement(By.xpath("//html")); findElements(By.tagName("body"));
getCurrentUrl(); getPageSource(); getTitle(); getWindowHandle();
Many thanks Sam
No comments:
Post a Comment