Set<String> windowId = cDriver.getWindowHandles(); // get window id of current window
Iterator<String> itererator = windowId.iterator();
String mainWinID = itererator.next();
String newAdwinID = itererator.next();
cDriver.switchTo().window(newAdwinID);
System.out.println(cDriver.getTitle());
Thread.sleep(3000);
cDriver.close();
cDriver.switchTo().window(mainWinID);
System.out.println(cDriver.getTitle());
Thread.sleep(2000);
Iterator<String> itererator = windowId.iterator();
String mainWinID = itererator.next();
String newAdwinID = itererator.next();
cDriver.switchTo().window(newAdwinID);
System.out.println(cDriver.getTitle());
Thread.sleep(3000);
cDriver.close();
cDriver.switchTo().window(mainWinID);
System.out.println(cDriver.getTitle());
Thread.sleep(2000);
No comments:
Post a Comment