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()

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;
  }
}