Webdriver hangs in new “about:blank” window that is transitioning to file download dialog

3,749 views
Skip to first unread message

sam smith

unread,
Sep 13, 2013, 3:13:39 PM9/13/13
to seleniu...@googlegroups.com
Hello All,

I need some help for the following issue with Webdriver, Java, and Firefox.

In the testing, when clicking on a link,
1) it will often open a new window with a normal web page.  OR
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 the link to determine whether the link connects to a normal web page or a downloadable file.

In both cases, driver.getWindowHandles().size() == 2, so I can 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:
findElement() (e.g., By.xpath(“//html”))
findElements() (e.g., By.tagName(“body”))
getCurrentUrl()
getPageSource()
getTitle()
getWindowHandle()

getWindowHandles() always returns 2 while new “about:blank” window 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.

Many thanks
Sam

1.png
2.png

DongXiang

unread,
Sep 16, 2013, 9:10:52 AM9/16/13
to seleniu...@googlegroups.com
WebDriver will hang when open a modal dialog except alert, prompt and file download dialog. you can perform the click 

in the other new created thread, use java robot to control the new created dialog, usaully use tab to switch focus from each 

element in the dialog finally perform click ok or cancel button in the dialog.

--david dong


Date: Fri, 13 Sep 2013 12:13:39 -0700
From: sams...@gmail.com
To: seleniu...@googlegroups.com
Subject: [selenium-users] Webdriver hangs in new “about:blank” window that is transitioning to file download dialog
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/cff08b4b-67ef-44c1-82ce-f4f66d8448d4%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

sam smith

unread,
Sep 16, 2013, 12:18:42 PM9/16/13
to seleniu...@googlegroups.com
Thanks David,

I was not trying to deal with a modal dialog, prompt, or file download dialog.

I also tried the following statement to suppress the file download dialog:
profile.setPreference("browser.download.manager.showWhenStarting",false);
But the "about:blank" new window still presents for 20 to 60 seconds before it disappears.  I need to switch to the newly opened window for testing, because it loads a normal webpage most of the time.  The testing execution hangs in this "about:blank" new window if it connects to a downloadable file.

Sam

DongXiang

unread,
Sep 17, 2013, 11:17:08 AM9/17/13
to seleniu...@googlegroups.com
Hi Sam,

The new open windown connects to a downloadable file will popup a modal dialog (file download dialog), it will make web driver hang. you can have a try, when the dialog popup, your webdriver hang here, manually close the dialog, check does web driver continue work.
As your said, it seems this new open window sometime opened with a file download dialog, sometime not, I guess your test must know what's the expected behavior firstly, otherwise you can't make a decision what's the next test step. specially under your case, the modal dialog make webdriver hang.

The other option may is use browser with silent download, like chrome or firefox. the dialog never popup, it may not block your case.
--david


Date: Mon, 16 Sep 2013 09:18:42 -0700
From: sams...@gmail.com
To: seleniu...@googlegroups.com
Subject: [selenium-users] Re: Webdriver hangs in new “about:blank” window that is transitioning to file download dialog
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.

sam smith

unread,
Sep 17, 2013, 1:51:46 PM9/17/13
to seleniu...@googlegroups.com
Thanks David,

I tried your suggestion.  After closing the file download dialog, the testing execution continues to hang.

I already tried the following statement to suppress the file download dialog,
firefoxProfile.setPreference("browser.download.manager.showWhenStarting", false);
the testing execution still hangs in this "about:blank" new window if it connects to a downloadable file, even after this new window disappears without the file download dialog.

1) The newly opened window usually loads a normal web page, to which I need to switch window in order to check the content.
2) The new window occasionally transitions from the "about:blank" window to a file download dialog.
Both cases are valid and expected behavior according to business requirements.

Is there a way that we can determine whether the new window connects to a normal webpage or a downloadable file, before or after we switch to this new window?  We are able to switch from the new window back to the parent window in both cases, but we need to switch to this new window for testing because it loads a normal web page most of the time.

The issue is that in both cases, before and after switching to the new window, driver.getWindowHandles().size() == 2
but if we use any of the following methods to determine what kind of this new window is (normal webpage or transitioning to a file dialog):

findElement() (e.g., By.xpath(“//html”))
findElements() (e.g., By.tagName(“body”))
getCurrentUrl()
getPageSource()
getTitle()
getWindowHandle()
the testing execution will hang if the new "about:blank" window connects to a downloadable file.

If the new window connects to file, it will present for 20 to 60 seconds before it disappears.  We could code the program to wait 60 seconds for the new window to disappear and then continue testing execution.  But we have a vast number of links to be tested every time, so this is not a good option.

Any thoughts, suggestions, and comments would be greatly appreciated.

Sam

Reply all
Reply to author
Forward
0 new messages