1 backdrop_web_test_case.php protected BackdropWebTestCase::xpath($xpath, array $arguments = array())

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.


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

array $arguments: An array of arguments with keys in the form ':name' matching the placeholders in the query. The values may be either strings or numeric values.

Return value

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


core/modules/simpletest/backdrop_web_test_case.php, line 2841


Test case for typical Backdrop tests.


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 false-ish values
    // to an empty array to allow foreach(...) constructions.
    return $result ? $result : array();
  else {
    return FALSE;