protected function BlockFormMessagesTest::clickElementWhenClickable in Drupal 9
Same name and namespace in other branches
- 8 core/modules/layout_builder/tests/src/FunctionalJavascript/BlockFormMessagesTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\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 120 
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);
}