My application opens up a new window on clicking a button and i need to perform some actions in that window. But the response getWindowHandles() method of selenium webdriver has only one window id in it. This happens especially if there is a delay in calling the getWindowHandles() after opening the new window. There is a known issue with selenium.
https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver#required-configuration
But even the solution for that is not working for me.
Code is as follows
DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
RemoteWebDriver driver = new
RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capabilities);
driver.get("https://<url>");
WebElement userName = driver.findElement(By.name("usr_name"));
userName.sendKeys("ABCD");
WebElement password = driver.findElement(By.name("usr_password"));
password.sendKeys("password");
WebElement login = driver.findElement(By.name("OK"));
login.click();
WebElement popup= driver.findElement(By.name("popup"));
popup.click();
Thread.sleep(1000);
Set<String> windowHandles = driver.getWindowHandles();
System.out.println(windowHandles);
The Set "windowHandles" will return only one window :
"[fcdad457-9090-4dfd-8da1-acb9d6f73f74]"
But if i remove the sleep. it will return two window ids :
[90cc6006-0679-450c-a5b3-6602bcb41a16, 7211bbfd-2616-4460-97e7-56c0e632c3bb]
I cannot remove the sleep as this is just a sample program and in the real application there will be some delay in between. Please let me know your thoughts.This issue is only for IE11.
Blue screen - Home Page;
Grey Screen - Popup
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…