/**
* Switch to child window. If there are only two windows.
* This is method is useful if you have only two windows (Parent and Child)
*/
public void switchToChildWindow()
{
String pwinhandle=driver.getWindowHandle();
Set<String> wins=driver.getWindowHandles();
for (String cwin : wins) {
driver.switchTo().window(cwin);
if (!pwinhandle.equals(cwin)) {
System.out.println("Switched to child window");
break;
}
else
{
System.out.println("Parent window");
}
}
}