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.

178 calls to WebTestBase::xpath()
ActionUpgradePathTest::testActionUpgrade in drupal/core/modules/system/lib/Drupal/system/Tests/Upgrade/ActionUpgradePathTest.php
Tests to see if actions were upgrade.
AggregatorRenderingTest::testBlockLinks in drupal/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorRenderingTest.php
Adds a feed block to the page and checks its links.
AggregatorRenderingTest::testFeedPage in drupal/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorRenderingTest.php
Creates a feed and checks that feed's page.
AnalyzeTest::testAnalyzeBasic in drupal/core/modules/views_ui/lib/Drupal/views_ui/Tests/AnalyzeTest.php
Tests that analyze works in general.
AreaEntityTest::testEntityArea in drupal/core/modules/views/lib/Drupal/views/Tests/Handler/AreaEntityTest.php
Tests the area handler.

... See full list

File

drupal/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php, line 1911
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;
  }
}