I'm using below code to switch into windows :
Set<String> handle=driver.getWindowHandles();
System.out.println(handle);
Iterator<String> it=handle.iterator();
String parent=it.next();
System.out.println("parent window =" +parent);
String child=it.next();
System.out.println("second child window =" +child);
driver.switchTo().window(child);
driver.findElement(By.xpath("//*[@id=\"fixHeader\"]/tbody/tr[2]/td[4]/a/span")).click();
Thread.sleep(3000);
String child2=it.next();
System.out.println("Third child window =" +child2);
driver.switchTo().window(child2);
But getting below exception :
Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"id","selector":"stylenumberH"}
findElement()
method when it cannot find a matching element in your page. This particular one show there is no element with id "stylenumberH". However, in your code there's no such selector, because you use only XPath selector. It looks like the code you pasted here is different than the one you executed :-) – dzieciou Aug 24 '18 at 8:34