Selenium not able to find new window handle in IE MODE but working in normal mode ( internet explorer ) | Selenium version 4.3.0.0

Viewed 29

I'm trying to switch to a new window that will open when i did the login in the previous page, After clicking the login button a new tab will be opened and gets closed immediately then a new window will be opened, this window handle is not recognizing by selenium IE driver in IE MODE but I'm able to switch to this new window while automating in normal internet explorer browser. The code that I'd tried to switch to that new windows is as shown below.

Thread.sleep(3000); // This delay is to avoid the new tab that gets closed immediately without this delay the driver is trying to switch to that new tab, after that any operation leads to throwing no browser exception. So this line is saving from the issue.
String desiredTitle = "";
while(!desiredTitle.contains("new window")) {
    for (String ewh : driver.getWindowHandles()) {
        desiredTitle = driver.switchTo().window(ewh).getTitle();
    }
}
1 Answers

There're known limitations in Selenium 4 for IE mode automation. One of the workarounds suggests waiting until the driver gets the handle. You can try the sample code provided in that doc.

Related