I am clicking on an icon , which results in new window. I want to move to that window ,and perform some operation, close that window, and then again switch back to Parent window.
I have written the below code to perform my action . But it seems not working and my method is not getting call as well .Please review the below code and help me .
public void collection_title() {
// It will return the parent window name as a String
String parent = driver.getWindowHandle();
Set<String> s = driver.getWindowHandles();
// Now iterate using Iterator
Iterator<String> I1 = s.iterator();
while (I1.hasNext()) {
String child_window = I1.next();
if (!parent.equals(child_window)) {
driver.switchTo().window(child_window);
System.out.println("the window name is "+driver.switchTo().window(child_window).getTitle());
}
//Code is generating random string
String uuid = UUID.randomUUID().toString();
edit_coln.sendKeys(uuid);
System.out.print("text got entered ");
}
}