function HttpKernelUiHelperTrait::getNodeElementsByXpath

Performs an xpath search on the contents of the internal browser.

The search is relative to the root element (HTML tag normally) of the page.

This method is identical to \Drupal\Tests\BrowserTestBase::xpath() and should be used when converting Browser tests to Kernel tests, as \Drupal\KernelTests\AssertContentTrait::xpath() which Kernel tests use does not have the same return type.

Parameters

string $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

\Behat\Mink\Element\NodeElement[] The list of elements matching the xpath expression.

File

core/tests/Drupal/Tests/HttpKernelUiHelperTrait.php, line 241

Class

HttpKernelUiHelperTrait
Provides UI helper methods using the HTTP kernel to make requests.

Namespace

Drupal\Tests

Code

protected function getNodeElementsByXpath($xpath, array $arguments = []) : array {
  $xpath = $this->assertSession()
    ->buildXPathQuery($xpath, $arguments);
  return $this->getSession()
    ->getPage()
    ->findAll('xpath', $xpath);
}

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