A plurality of switching windows Window

Window switch

  • Further operation of the page elements of a window, the window must first switching
  • Switching manner: name passed to the operating handle or window handle

driver.switchTo.window (nameOrHandle);
how to get to the window handle
driver.getWindowHandle ();
driver.getWindowHandles ();
EG:
chromeDriver.get (url);
chromeDriver.findElement (By.id ( "AA")) sendKeys. ( "this is the first window");
System.out.println ( "front jump window handle:" + chromeDriver.getWindowHandle ());
time.sleep (2000)
System.out.println ( "Jump after window handle: "+ chromeDriver.getWindowHandle ());
the Set <String> handles chromeDriver.getWindowHandles = ();
for (String handle: handles) {
 . chromeDriver.switchTo () window (handle);
 IF (chromeDriver.getTitle ( ) .equals ( "b.html")
  BREAK;
}
. chromeDriver.findElement (By.id ( "BB")) SendKeys ( "this is the second window");

Guess you like

Origin www.cnblogs.com/JacquelineQA/p/12593766.html