Dialog opened with showModalDialog has no window handle, cannot interact with dialog
Meta -
OS:
Windows 7
Selenium Version:
3.7.1
Browser:
Internet Explorer
Browser Version:
11.0.9600.18665, Update Versions: 11.0.42
Expected Behavior -
After opening a modal dialog, the dialog should have its own handle string when calling InternetExplorerDriver.getWindowHandles().
Actual Behavior -
The modal dialog is never given a handle. It does not appear possible to interact with the modal dialog in any way.
Steps to reproduce -
I believe this is an environment configuration issue, as this issue suddenly began without our making any changes to the Selenium version, IEDriverServer, or installing any Windows updates. Unfortunately we do not have a record of changes possibly made to the environment, so I cannot say what exactly caused this to start.
The logs report the following error:
W 2017-11-29 15:34:29:886 BrowserFactory.cpp(353) -2147024809 [The parameter is incorrect.]: Unable to convert document object pointer to IHTMLDocument2 object via ObjectFromLresult
Complete logs from failing run: ielogs-fails.txt
Complete logs from passing run on a different machine: ielog-success.txt
index.html:
<html><body>
<div id="click" onclick="window.showModalDialog('modal.html', 'test', 'dialogheight:200px;dialogwidth:200px')">click</div>
</body></html>
modal.html
<html><body><div id="inmodal">inmodal</div></body></html>
JUnit:
@Test
public void testShowModalDialog() throws Throwable {
System.setProperty("webdriver.ie.driver", "C:/path/to/IEDriverServer.exe");
InternetExplorerDriver driver = null;
try {
InternetExplorerOptions options = new InternetExplorerOptions();
options.setCapability(InternetExplorerDriver.LOG_FILE, "C:/path/to/log.txt");
options.setCapability(InternetExplorerDriver.LOG_LEVEL, "TRACE");
driver = new InternetExplorerDriver(options);
driver.get("http://path/to/index.html");
WebElement div = driver.findElement(By.id("click"));
div.click();
Thread.sleep(10*1000);
for (String handle : driver.getWindowHandles()) {
System.out.println(handle);
}
} finally {
if (driver != null) {
driver.quit();
}
}
}
I'm experiencing the same issue using Chrome. The javascript call is
var popup = new window.parent.Popup(url, window.self, "frameborder=0,scrolling=0,okcancel=0,width=490,height=470,title=" + title);
when calling driver.WindowHandles, only 1 handle exists and it is the parent page.
Apparently, this issue also happens in Firefox. see (https://sqa.stackexchange.com/questions/13232/unable-to-switch-to-a-popup)
Is this still happening with the most recent version of Selenium and the browser drivers?
Closing this issue as it went stale, feel free to create a new one if the issue is still present after upgrading to the most recent version of Selenium, GeckoDriver and Firefox. Also consider to post your issue on one of our support channels (https://www.selenium.dev/support/).