【发布时间】:2023-05-22 12:15:01
【问题描述】:
我需要关闭一个子窗口并切换回父窗口来执行一些操作。
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);
}
【问题讨论】:
-
请格式化源代码
-
我认为下面的链接可能对此有用。 *.com/questions/14620253/…