コード例 #1
0
  @Override
  public Windows getWindows() {

    Windows ret = new Windows();
    WebDriver d = getDriver();
    ret.setCurrent(d.getWindowHandle());
    ret.setAll(d.getWindowHandles());
    return ret;
  }
コード例 #2
0
  @Override
  public String waitForNewWindow(final Windows windows, int seconds) {
    WebDriver d = getDriver();
    LOGGER.debug("waitForNewWindow: existing=" + windows.getAll());
    waitFor(
        seconds,
        new ExpectedCondition<Boolean>() {
          public Boolean apply(WebDriver d) {
            return (d.getWindowHandles().size() > windows.getAll().size());
          }
        });
    Set<String> handles = d.getWindowHandles();
    LOGGER.debug("waitForNewWindow: handles=" + handles);

    handles.removeAll(windows.getAll());
    if (handles.size() > 0) {
      String handle = handles.iterator().next();
      LOGGER.debug("waitForNewWindow: found new window - handle=" + handle);
      return handle;
    }
    LOGGER.debug("waitForNewWindow: did not find new window");
    return null;
  }