diff --git a/core/modules/simpletest/src/BrowserTestBase.php b/core/modules/simpletest/src/BrowserTestBase.php index 2559bb4..8cbfe4a 100644 --- a/core/modules/simpletest/src/BrowserTestBase.php +++ b/core/modules/simpletest/src/BrowserTestBase.php @@ -26,8 +26,8 @@ use Drupal\Core\Test\TestRunnerKernel; use Drupal\Core\Url; use Drupal\user\UserInterface; +use Symfony\Component\CssSelector\CssSelector; use Symfony\Component\HttpFoundation\Request; -use Zumba\Mink\Driver\PhantomJSDriver; /** * Provides a test case for functional Drupal tests. @@ -1364,7 +1364,7 @@ protected function drupalUserIsLoggedIn(UserInterface $account) { * Optional message to show alongside the assertion. */ protected function assertElementPresent($css_selector, $message = '') { - $this->assertNotEmpty($this->getSession()->getDriver()->find($this->selectorToXpath($css_selector)), $message); + $this->assertNotEmpty($this->getSession()->getDriver()->find(CssSelector::toXPath($css_selector)), $message); } /** @@ -1376,7 +1376,7 @@ protected function assertElementPresent($css_selector, $message = '') { * Optional message to show alongside the assertion. */ protected function assertElementNotPresent($css_selector, $message = '') { - $this->assertEmpty($this->getSession()->getDriver()->find($this->selectorToXpath($css_selector)), $message); + $this->assertEmpty($this->getSession()->getDriver()->find(CssSelector::toXPath($css_selector)), $message); } /** @@ -1386,20 +1386,7 @@ protected function assertElementNotPresent($css_selector, $message = '') { * The CSS selector identifying the element to click. */ protected function click($css_selector) { - $this->getSession()->getDriver()->click($this->selectorToXpath($css_selector)); - } - - /** - * Converts the given CSS selector to an XPath expression. - * - * @param string $css_selector - * The CSS selector to convert. - * - * @return string - * The converted XPath expression. - */ - protected function selectorToXpath($css_selector) { - return $this->getSession()->getSelectorsHandler()->selectorToXpath('css', $css_selector); + $this->getSession()->getDriver()->click(CssSelector::toXPath($css_selector)); } /** diff --git a/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php b/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php index 29eb744..deeb026 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php @@ -3,6 +3,7 @@ namespace Drupal\FunctionalJavascriptTests; use Drupal\simpletest\BrowserTestBase; +use Symfony\Component\CssSelector; use Zumba\Mink\Driver\PhantomJSDriver; /** @@ -42,7 +43,7 @@ protected function initMink() { * Optional message to show alongside the assertion. */ protected function assertElementVisible($css_selector, $message = '') { - $this->assertTrue($this->getSession()->getDriver()->isVisible($this->selectorToXpath($css_selector)), $message); + $this->assertTrue($this->getSession()->getDriver()->isVisible(CssSelector::toXPath($css_selector)), $message); } /** @@ -54,7 +55,7 @@ protected function assertElementVisible($css_selector, $message = '') { * Optional message to show alongside the assertion. */ protected function assertElementNotVisible($css_selector, $message = '') { - $this->assertFalse($this->getSession()->getDriver()->isVisible($this->selectorToXpath($css_selector)), $message); + $this->assertFalse($this->getSession()->getDriver()->isVisible(CssSelector::toXPath($css_selector)), $message); } /**