You are here

public function WindowTest::testWindow in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/behat/mink/driver-testsuite/tests/Js/WindowTest.php \Behat\Mink\Tests\Driver\Js\WindowTest::testWindow()

File

vendor/behat/mink/driver-testsuite/tests/Js/WindowTest.php, line 9

Class

WindowTest

Namespace

Behat\Mink\Tests\Driver\Js

Code

public function testWindow() {
  $this
    ->getSession()
    ->visit($this
    ->pathTo('/window.html'));
  $session = $this
    ->getSession();
  $page = $session
    ->getPage();
  $webAssert = $this
    ->getAssertSession();
  $page
    ->clickLink('Popup #1');
  $session
    ->switchToWindow(null);
  $page
    ->clickLink('Popup #2');
  $session
    ->switchToWindow(null);
  $el = $webAssert
    ->elementExists('css', '#text');
  $this
    ->assertSame('Main window div text', $el
    ->getText());
  $session
    ->switchToWindow('popup_1');
  $el = $webAssert
    ->elementExists('css', '#text');
  $this
    ->assertSame('Popup#1 div text', $el
    ->getText());
  $session
    ->switchToWindow('popup_2');
  $el = $webAssert
    ->elementExists('css', '#text');
  $this
    ->assertSame('Popup#2 div text', $el
    ->getText());
  $session
    ->switchToWindow(null);
  $el = $webAssert
    ->elementExists('css', '#text');
  $this
    ->assertSame('Main window div text', $el
    ->getText());
}