You are here

public function WindowTrait::switchToWindow in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/jcalderonzumba/mink-phantomjs-driver/src/WindowTrait.php \Zumba\Mink\Driver\WindowTrait::switchToWindow()

Switches to window by name if possible

Parameters

$name:

Throws

DriverException

File

vendor/jcalderonzumba/mink-phantomjs-driver/src/WindowTrait.php, line 33

Class

WindowTrait
Class WindowTrait @package Zumba\Mink\Driver

Namespace

Zumba\Mink\Driver

Code

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}");
  }
}