function BlockFormMessagesTest::clickElementWhenClickable
Attempts to click an element until it is in a clickable state.
@todo Replace this method with general solution for random click() test failures in https://www.drupal.org/node/3032275.
Parameters
\Behat\Mink\Element\NodeElement $element: The element to click.
int $timeout: (Optional) Timeout in milliseconds, defaults to 10000.
1 call to BlockFormMessagesTest::clickElementWhenClickable()
- BlockFormMessagesTest::testValidationMessage in core/
modules/ layout_builder/ tests/ src/ FunctionalJavascript/ BlockFormMessagesTest.php - Tests that validation messages are shown on the block form.
File
-
core/
modules/ layout_builder/ tests/ src/ FunctionalJavascript/ BlockFormMessagesTest.php, line 123
Class
- BlockFormMessagesTest
- Tests that messages appear in the off-canvas dialog with configuring blocks.
Namespace
Drupal\Tests\layout_builder\FunctionalJavascriptCode
protected function clickElementWhenClickable(NodeElement $element, $timeout = 10000) {
$page = $this->getSession()
->getPage();
$result = $page->waitFor($timeout / 1000, function () use ($element) {
try {
$element->click();
return TRUE;
} catch (UnknownError $exception) {
if (strstr($exception->getMessage(), 'not clickable') === FALSE) {
// Rethrow any unexpected UnknownError exceptions.
throw $exception;
}
return NULL;
}
});
$this->assertTrue($result);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.