我需要关闭子窗口并切换回父窗口才能执行某些操作。如何使用硒webdriver从父窗口切换到子窗口
public static void nextTab() throws InterruptedException {
Set winSet = UIPage.getBaseWindow().getWindowHandles();
List winList = new ArrayList(winSet);
String newTab = winList.get(winList.size() - 1); UIPage.getBaseWindow().switchTo().window(newTab);
Thread.sleep(Constant.LONG_TIMEOUT_500);
}
public static void prevTab() {
Set winSet = UIPage.getBaseWindow().getWindowHandles();
List winList = new ArrayList(winSet);
UIPage.getBaseWindow().close();
String oldTab = winList.get(winList.size() - 2); //System.out.println(oldTab);
UIPage.getBaseWindow().switchTo().window(oldTab);
}
请格式化源代码 – dpassy
我想下面链接可能对这项有益的。 http://stackoverflow.com/questions/14620253/how-to-switch-control-from-child-window-to-parent-window-in-selenium-webdriver?rq=1 – MamathaMacherla