-2
雖然做處理Windows硒 - 的Java,Java中它顯示一個1窗口中打開,如果我用C#試過顯示2。我無法得到打開第二個窗口的窗口句柄(其實這是一個信息對話框,我需要點擊OK按鈕,然後繼續父窗口)在Java.Please幫我整理了這一點有問題,而這樣做的窗口句柄
雖然做處理Windows硒 - 的Java,Java中它顯示一個1窗口中打開,如果我用C#試過顯示2。我無法得到打開第二個窗口的窗口句柄(其實這是一個信息對話框,我需要點擊OK按鈕,然後繼續父窗口)在Java.Please幫我整理了這一點有問題,而這樣做的窗口句柄
你應該搜索互聯網上的解決方案,並試圖自己動手第一,遠遠低於代碼可以幫助你:
//Before you click, get main window handle
String mainhandle=driver.getWindowHandle();
//Enter code to click button
new WebDriverWait(driver, 60)
.ignoring(NoAlertPresentException.class)
.until(ExpectedConditions.alertIsPresent());
flag=0;
while(flag==0){
try{
driver.switchTo().alert().accept();
flag=1;
}
catch(Exception e){
driver.manage().timeouts().implicitlyWait(1,TimeUnit.SECONDS);
}
}
driver.switchTo().window(mainhandle);