1
在我的網站,當我在主頁上搜索任何東西它的開放一個葉窗和一個隱藏彈出式背後 window.Using硒我想正確或不知道它的開放,也藉此兩個窗口鏈接。硒獲取彈出和隱藏彈出式當前打開的鏈接
我試過,但它不工作
public class Utility
{
public static WebDriver getHandleToWindow(String title){
//parentWindowHandle = WebDriverInitialize.getDriver().getWindowHandle(); // save the current window handle.
WebDriver popup = null;
Set<String> windowIterator = WebDriverInitialize.getDriver().getWindowHandles();
System.err.println("No of windows : " + windowIterator.size());
for (String s : windowIterator) {
String windowHandle = s;
popup = WebDriverInitialize.getDriver().switchTo().window(windowHandle);
System.out.println("Window Title : " + popup.getTitle());
System.out.println("Window Url : " + popup.getCurrentUrl());
if (popup.getTitle().equals(title)){
System.out.println("Selected Window Title : " + popup.getTitle());
return popup;
}
}
System.out.println("Window Title :" + popup.getTitle());
System.out.println();
return popup;
}
}
WebDriverInitialize這個代碼庫的問題。你建議我該如何解決。 – zsbappa
@zsbappa你能顯示錯誤嗎? – Buaban