diff --git a/tests/src/FunctionalJavascript/ProjectBrowserUiTestTrait.php b/tests/src/FunctionalJavascript/ProjectBrowserUiTestTrait.php index bf667b2344168f1d079aed4f32849748c8fb0696..895ab77d64ab552d25c19ef2e3b267d5e6b0ba4f 100644 --- a/tests/src/FunctionalJavascript/ProjectBrowserUiTestTrait.php +++ b/tests/src/FunctionalJavascript/ProjectBrowserUiTestTrait.php @@ -120,12 +120,25 @@ trait ProjectBrowserUiTestTrait { * When TRUE, do not wait for a rerender after entering a search string. */ protected function clickWithWait(string $css_selector, string $wait_for_text = '', bool $bypass_wait = FALSE) { + $do_click = function () use ($css_selector): void { + $element = $this->assertSession()->elementExists('css', $css_selector); + + // In W3C mode, you cannot click an <option> element. We have to set the + // value of the containing <select> correctly. + if (strtolower($element->getTagName()) === 'option') { + $element->getParent()->setValue($element->getValue()); + } + else { + $element->click(); + } + }; + if ($bypass_wait) { - $this->assertSession()->elementExists('css', $css_selector)->click(); + $do_click(); } else { $this->preFilterWait(); - $this->assertSession()->elementExists('css', $css_selector)->click(); + $do_click(); $this->postFilterWait(); }