protected function DrupalWebTestCase::xpath

7.x drupal_web_test_case.php protected DrupalWebTestCase::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.

Return value

The return value of the xpath search. For details on the xpath string format and return values see the SimpleXML documentation,

111 calls to DrupalWebTestCase::xpath()
AggregatorRenderingTestCase::testBlockLinks in drupal/modules/aggregator/aggregator.test
Adds a feed block to the page and checks its links.
AggregatorRenderingTestCase::testFeedPage in drupal/modules/aggregator/aggregator.test
Creates a feed and checks that feed's page.
AJAXMultiFormTestCase::testMultiForm in drupal/modules/simpletest/tests/ajax.test
Test that a page with the 'page_node_form' included twice works correctly.
BlockTestCase::testCustomBlock in drupal/modules/block/block.test
Test creating custom block, moving it to a specific region and then deleting it.
BookTestCase::checkBookNode in drupal/modules/book/book.test
Checks the outline of sub-pages; previous, up, and next.

... See full list


drupal/modules/simpletest/drupal_web_test_case.php, line 2528


Test case for typical Drupal 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 falsish values
    // to an empty array to allow foreach(...) constructions.
    return $result ? $result : array();
  else {
    return FALSE;