protected function WebTestBase::xpath

Perform an xpath search on the contents of the internal browser. The search is relative to the root element (HTML tag normally) of the page.

Parameters

$xpath: The xpath string to use in the search.

Return value

The return value of the xpath search. For details on the xpath string format and return values see the SimpleXML documentation, http://php.net/manual/function.simplexml-element-xpath.php.

139 calls to WebTestBase::xpath()
AggregatorRenderingTest::testBlockLinks in drupal/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorRenderingTest.php
Add a feed block to the page and checks its links.
AggregatorRenderingTest::testFeedPage in drupal/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorRenderingTest.php
Create a feed and check that feed's page.
AreaTest::testRenderAreaToken in drupal/core/modules/views/lib/Drupal/views/Tests/Handler/AreaTest.php
Tests global tokens.
BlockTest::testCustomBlock in drupal/core/modules/block/lib/Drupal/block/Tests/BlockTest.php
Test creating custom block, moving it to a specific region and then deleting it.
BookTest::checkBookNode in drupal/core/modules/book/lib/Drupal/book/Tests/BookTest.php
Check the outline of sub-pages; previous, up, and next; and printer friendly version.

... See full list

File

drupal/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php, line 1703
Definition of Drupal\simpletest\WebTestBase.

Class

WebTestBase
Test case for typical Drupal tests.

Namespace

Drupal\simpletest

Code

protected function xpath($xpath, array $arguments = array()) {
  if ($this
    ->parse()) {
    $xpath = $this
      ->buildXPathQuery($xpath, $arguments);
    $result = $this->elements
      ->xpath($xpath);

    // Some combinations of PHP / libxml versions return an empty array
    // instead of the documented FALSE. Forcefully convert any falsish values
    // to an empty array to allow foreach(...) constructions.
    return $result ? $result : array();
  }
  else {
    return FALSE;
  }
}