[英]How to switch control from child window to parent window if the child window close on clicking a button?
[英]How to close parent window and continue execution on a child window
我有一種方法,我需要切換到子窗口以繼續執行,並且不再需要父窗口。 那么,如何關閉父窗口並僅在子窗口上繼續執行?
public ServicesPage clickOnBookAppointmentLink() {
getAction().click(SalonServicesLocators.BOOK_Service_LINK);
HashMap<String, String> childWindowhandle = new HashMap<>();
getWaits().waitForWindowToBeVisible(2, 60);
childWindowhandle = getAction().getWindowHandles();
getAction().switchToWindow(childWindowhandle, "CHILD");
getAction().goToURL(Cont.MyURL_URL); // to navigate to the services booking page URL
return this;
}
您可以在代碼中添加以下行: driver.switchTo().defaultContent().close(); 它將關閉父窗口,您可以繼續在子窗口上執行。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.