Selenium video 14 windowhandlers | Selenium Forum
M
Posted on 17/04/2016
Hi

I tried the below code in chrome as well in IE, There is no new window open, in the same window the links get open and window count always one
System.setProperty("webdriver.ie.driver", "C:\\tools\\MicrosoftWebDriver.exe");
WebDriver driver = new InternetExplorerDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.manage().timeouts().pageLoadTimeout(15, TimeUnit.SECONDS);

Set<String> windowIds = driver.getWindowHandles();
System.out.println("Total windows ==="+windowIds.size());
Iterator<String> it = windowIds.iterator();
System.out.println(it.next());

System.out.println("===================");
driver.get("http://www.rediff.com/");
windowIds = driver.getWindowHandles();
it = windowIds.iterator();
String wid1 = it.next();
String wid2 = it.next();
System.out.println(wid1);
System.out.println(wid2);
System.out.println("Total windows =========="+windowIds.size());

output
Total windows ===1
1
===================
Exception in thread "main" java.util.NoSuchElementException
at java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java:713)
at java.util.LinkedHashMap$LinkedKeyIterator.next(LinkedHashMap.java:734)
at module12.rediff4.main(rediff4.java:34)

M
Replied on 18/04/2016

send a screen shot.


M
Replied on 18/04/2016

not sure which screenshot you mean. here I am sending the code screenshot

The outpur always shows one window count since the driver.get(url) get open in the same window, it doesn't open new instance of IE. I have tried in chrome also. the same result

Responsive image

M
Replied on 20/04/2016

there is no pop up in ie. so, can't do anything.


M
Replied on 23/04/2016

I tried on chrome too. The new window opens in the existing window so the number of window count always shows one


M
Replied on 23/04/2016

problem is with the website not with code. website doesn't open pop up with IE.