There is a web application with a button, after clicking on the button, the 2 window opens and you need to switch to it. The problem is that if I take the getWindowHandle () of the second window, then it is the same as the first

String originalWindow = driver.getWindowHandle(); final Set<String> oldWindowsSet = driver.getWindowHandles(); util.elementVisible(By.id("ucBillingRepList_lvReportList_ctrl0_hlRep")).click(); String newWindow = (new WebDriverWait(driver, 10)) .until(new ExpectedCondition<String>() { public String apply(WebDriver driver) { Set<String> newWindowsSet = driver.getWindowHandles(); newWindowsSet.removeAll(oldWindowsSet); return newWindowsSet.size() > 0 ? newWindowsSet.iterator().next() : null; } } ); driver.switchTo().window(newWindow); driver.close(); driver.switchTo().window(originalWindow); 

and this is what it says:

 Started InternetExplorerDriver server (32-bit) 

3.4.0.0 Listening on port 22062 Jul 12, 2017 10:55:24 AM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detect dialect: OSS org.openqa.selenium.NoSuchWindowException: Unable to get browser (WARNING: The server didn’t provide any stacktrace information) Command duration or timeout: 31 milliseconds Build info: version: '3.4.0', revision: 'unknown', time: 'unknown' System info: host: 'KHO-0493 -WS ', ip: '10 .4.69.161', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10 .0 ', java.version:' 1.8.0_131 'Driver info: org .openqa.selenium. 3000.0, ie.useLegacyFileUploadDialogHandling = false, nativeEvents = true, ie.ensureCleanSession = true, elementScrollBehavior = 0.0, ie.browserCommandLineSw itches =, requireWindowFocus = false, initialBrowserUrl = https://cnbilllm.fuib.com/main.aspx , ignoreProtectedModeSettings = true, enableElementCacheCleanup = true}, browserName = internet explorer, pageLoadStrategy = normal, javascriptEnabled = true, you can use Internet Explorer = WINDOWS, unexpectedAlertBehavior = dismiss}] Session ID: a73aef0e-cbd2-4f0a-a46b-67237e3a12ad

    1 answer 1

    I figured out that if someone has the same problem with IE, just take off caps.setCapability (InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);