code: public String openNewWindow(final Runnable openCommand, final long timeoutSeconds) {
  		String oldHandle = webDriver.getWindowHandle();
  		final Set<String> existingWindowHandles = webDriver.getWindowHandles();
  
  		openCommand.run();
  
  		Function<WebDriver, String> function = new Function<WebDriver, String>() {
  			@Override
  			public String apply(final WebDriver input) {
  				Set<String> newWindowHandles = webDriver.getWindowHandles();
  				SetView<String> newWindows = difference(newWindowHandles, existingWindowHandles);
  				if (newWindows.isEmpty()) {
  					throw new NotFoundException("No new window found.");
  				}
  				return getOnlyElement(newWindows);
  			}
  
  			@Override
  			public String toString() {
  				return "new window to open";
  			}
  		};
  
  		String newHandle = waitFor(function, timeoutSeconds);
  		webDriver.switchTo().window(newHandle);
  		return oldHandle;
  	}
docs: Opens a new window and switches to it. The window to switch to is determined by diffing
  the given {@code existingWindowHandles} with the current ones. The difference must be
  exactly one window handle which is then used to switch to.
  
  @param openCommand
  logic for opening the new window
  @param timeoutSeconds
  the timeout in seconds to wait for the new window to open
  @return the handle of the window that opened the new window