diff -u b/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php b/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php --- b/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php @@ -63,8 +63,9 @@ //@todo Remove when https://github.com/jcalderonzumba/gastonjs/issues/19 // is fixed. Currently clicking anchors/buttons with nested elements is // not possible, which is why we use Javascript's native click method. - $css_selector = addcslashes($css_selector, "'"); - $this->getSession()->executeScript("document.querySelectorAll('" . $css_selector . "')[0].click()"); + $xpath = $this->cssSelectToXpath($css_selector); + $xpath = addcslashes($xpath, "'"); + $this->getSession()->executeScript("document.evaluate('" . $xpath . "', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.click()"); } }