You are here

protected function UiHelperTrait::cssSelectToXpath in Drupal 10

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/UiHelperTrait.php \Drupal\Tests\UiHelperTrait::cssSelectToXpath()

Translates a CSS expression to its XPath equivalent.

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

Parameters

string $selector: CSS selector to use in the search.

bool $html: (optional) Enables HTML support. Disable it for XML documents.

string $prefix: (optional) The prefix for the XPath expression.

Return value

string The equivalent XPath of a CSS expression.

File

core/tests/Drupal/Tests/UiHelperTrait.php, line 479

Class

UiHelperTrait
Provides UI helper methods.

Namespace

Drupal\Tests

Code

protected function cssSelectToXpath($selector, $html = TRUE, $prefix = 'descendant-or-self::') {
  return (new CssSelectorConverter($html))
    ->toXPath($selector, $prefix);
}