You are here

class WindowTest 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

Hierarchy

  • class \Behat\Mink\Tests\Driver\TestCase extends \Behat\Mink\Tests\Driver\PHPUnit_Framework_TestCase

Expanded class hierarchy of WindowTest

File

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

Namespace

Behat\Mink\Tests\Driver\Js
View source
class WindowTest extends TestCase {
  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());
  }
  public function testGetWindowNames() {
    $this
      ->getSession()
      ->visit($this
      ->pathTo('/window.html'));
    $session = $this
      ->getSession();
    $page = $session
      ->getPage();
    $windowName = $this
      ->getSession()
      ->getWindowName();
    $this
      ->assertNotNull($windowName);
    $page
      ->clickLink('Popup #1');
    $page
      ->clickLink('Popup #2');
    $windowNames = $this
      ->getSession()
      ->getWindowNames();
    $this
      ->assertNotNull($windowNames[0]);
    $this
      ->assertNotNull($windowNames[1]);
    $this
      ->assertNotNull($windowNames[2]);
  }
  public function testResizeWindow() {
    $this
      ->getSession()
      ->visit($this
      ->pathTo('/index.html'));
    $session = $this
      ->getSession();
    $session
      ->resizeWindow(400, 300);
    $session
      ->wait(1000, 'false');
    $script = 'return Math.abs(window.outerHeight - 300) <= 100 && Math.abs(window.outerWidth - 400) <= 100;';
    $this
      ->assertTrue($session
      ->evaluateScript($script));
  }
  public function testWindowMaximize() {
    $this
      ->getSession()
      ->visit($this
      ->pathTo('/index.html'));
    $session = $this
      ->getSession();
    $session
      ->maximizeWindow();
    $session
      ->wait(1000, 'false');
    $script = 'return Math.abs(screen.availHeight - window.outerHeight) <= 100;';
    $this
      ->assertTrue($session
      ->evaluateScript($script));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
TestCase::$config private static property
TestCase::$mink private static property Mink session manager.
TestCase::checkRequirements protected function
TestCase::createDriver protected function Creates a new driver instance.
TestCase::findById protected function
TestCase::getAssertSession protected function Returns assert session.
TestCase::getConfig private static function
TestCase::getSession protected function Returns session.
TestCase::mapRemoteFilePath protected function Map remote file path.
TestCase::onNotSuccessfulTest protected function
TestCase::pathTo protected function
TestCase::safePageWait protected function Waits for a condition to be true, considering than it is successful for drivers not supporting wait().
TestCase::setUpBeforeClass public static function Initializes the test case.
TestCase::tearDown protected function
WindowTest::testGetWindowNames public function
WindowTest::testResizeWindow public function
WindowTest::testWindow public function
WindowTest::testWindowMaximize public function