You are here

public function TraversingTest::testElementsTraversing in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/behat/mink/driver-testsuite/tests/Basic/TraversingTest.php \Behat\Mink\Tests\Driver\Basic\TraversingTest::testElementsTraversing()

File

vendor/behat/mink/driver-testsuite/tests/Basic/TraversingTest.php, line 22

Class

TraversingTest

Namespace

Behat\Mink\Tests\Driver\Basic

Code

public function testElementsTraversing() {
  $this
    ->getSession()
    ->visit($this
    ->pathTo('/index.html'));
  $page = $this
    ->getSession()
    ->getPage();
  $title = $page
    ->find('css', 'h1');
  $this
    ->assertNotNull($title);
  $this
    ->assertEquals('Extremely useless page', $title
    ->getText());
  $this
    ->assertEquals('h1', $title
    ->getTagName());
  $strong = $page
    ->find('xpath', '//div/strong[3]');
  $this
    ->assertNotNull($strong);
  $this
    ->assertEquals('pariatur', $strong
    ->getText());
  $this
    ->assertEquals('super-duper', $strong
    ->getAttribute('class'));
  $this
    ->assertTrue($strong
    ->hasAttribute('class'));
  $strong2 = $page
    ->find('xpath', '//div/strong[2]');
  $this
    ->assertNotNull($strong2);
  $this
    ->assertEquals('veniam', $strong2
    ->getText());
  $this
    ->assertEquals('strong', $strong2
    ->getTagName());
  $this
    ->assertNull($strong2
    ->getAttribute('class'));
  $this
    ->assertFalse($strong2
    ->hasAttribute('class'));
  $strongs = $page
    ->findAll('css', 'div#core > strong');
  $this
    ->assertCount(3, $strongs);
  $this
    ->assertEquals('Lorem', $strongs[0]
    ->getText());
  $this
    ->assertEquals('pariatur', $strongs[2]
    ->getText());
  $element = $page
    ->find('css', '#some-element');
  $this
    ->assertNotNull($element);
  $this
    ->assertEquals('some very interesting text', $element
    ->getText());
  $this
    ->assertEquals("\n            some <div>very\n            </div>\n" . "<em>interesting</em>      text\n        ", $element
    ->getHtml());
  $this
    ->assertTrue($element
    ->hasAttribute('data-href'));
  $this
    ->assertFalse($element
    ->hasAttribute('data-url'));
  $this
    ->assertEquals('http://mink.behat.org', $element
    ->getAttribute('data-href'));
  $this
    ->assertNull($element
    ->getAttribute('data-url'));
  $this
    ->assertEquals('div', $element
    ->getTagName());
}