public function switchToWindow($name = null) {
    $handles = $this->browser->windowHandles();
    if ($name === null) {
      //null means back to the main window
      return $this->browser->switchToWindow($handles[0]);
    }

    $windowHandle = $this->browser->windowHandle($name);
    if (!empty($windowHandle)) {
      $this->browser->switchToWindow($windowHandle);
    } else {
      throw new DriverException("Could not find window handle by a given window name: $name");
    }

  }
public function switchToWindow($name = null) {
    $handles = $this->browser->windowHandles();
    if ($name === null) {
      //null means back to the main window
      return $this->browser->switchToWindow($handles[0]);
    }

    $windowHandle = $this->browser->windowHandle($name);
    if (!empty($windowHandle)) {
      $this->browser->switchToWindow($windowHandle);
    } else {
      throw new DriverException("Could not find window handle by a given window name: $name");
    }

  }
public function switchToWindow ( $ name = null ) { $ handles = $ this -> browser -> windowHandles ( ) ; if ( $ name === null ) { //null means back to the main window return $ this -> browser -> switchToWindow ( $ handles [ 0 ] ) ; } $ windowHandle = $ this -> browser -> windowHandle ( $ name ) ; if ( ! empty ( $ windowHandle ) ) { $ this -> browser -> switchToWindow ( $ windowHandle ) ; } else { throw new DriverException ( "Could not find window handle by a given window name: $name" ) ; } }
Switches to window by name if possible
@param $name
@throws DriverException
Switches to window by name if possible