function DrupalWebTestCase::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.

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

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.

126 calls to DrupalWebTestCase::xpath()
AggregatorRenderingTestCase::testBlockLinks in modules/aggregator/aggregator.test
Adds a feed block to the page and checks its links.
AggregatorRenderingTestCase::testFeedPage in modules/aggregator/aggregator.test
Creates a feed and checks that feed's page.
AJAXFormPageCacheTestCase::getFormBuildId in modules/simpletest/tests/ajax.test
Return the build id of the current form.
AJAXMultiFormTestCase::testMultiForm in modules/simpletest/tests/ajax.test
Test that a page with the 'page_node_form' included twice works correctly.
BlockTestCase::testCustomBlock in modules/block/block.test
Test creating custom block, moving it to a specific region and then deleting it.

... See full list

File

modules/simpletest/drupal_web_test_case.php, line 2924

Class

DrupalWebTestCase
Test case for typical Drupal tests.

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.