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