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

3 calls to BrowserTestBase::cssSelectToXpath()
ResponsiveImageFieldUiTest::testResponsiveImageFormatterUi in core/modules/responsive_image/src/FunctionalJavascript/ResponsiveImageFieldUiTest.php
Tests formatter settings.
WebDriverTestBase::assertElementNotVisible in core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php
Asserts that the element with the given CSS selector is not visible.
WebDriverTestBase::assertElementVisible in core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php
Asserts that the element with the given CSS selector is visible.

File

core/tests/Drupal/Tests/BrowserTestBase.php, line 615

Class

BrowserTestBase
Provides a test case for functional Drupal tests.

Namespace

Drupal\Tests

Code

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

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