I am facing a serious issue, After following all possible post related to this issue, still not able to figure it out . My problem is I am not able to switch to the child browser window hence can not able to perform an action on it.
// Store and Print the name of the First window on the console
String parentWindowHandle= driver.getWindowHandle();
System.out.println("Parent window-->" +parentWindowHandle);
// Click on the Button
driver.findElement(
By.xpath("html/body/div[1]/div[2]/div/div[2]/div/div[2]/form/div[13]/div[2]/span/ul/li/a"))
.click();
// Store and Print the name of all the windows open
Set<String> WindowHandles = driver.getWindowHandles();
System.out.println("All possible window-->" +WindowHandles);
// Pass a window handle to the other window
for (String childWindow : driver.getWindowHandles()) {
System.out.println("Child window-->" +childWindow);
driver.switchTo().window(childWindow);
// PERFORM THE ACTION IN NEW WINDOW
System.out.println("We are in second window");
driver.findElement(By.xpath("//td[@title='Vat UK']")).click();
}
After clicking on the button a new browser window opens and that is the end of the story. It only gives the id of the parent window.
If I manually click on the child window it works and test pass, shows all possible outputs.
Please help me, how to handle/solve this ..