function OptionsFieldUIAllowedValuesTest::pressEnterOnElement

Same name in other branches
  1. 11.x core/modules/options/tests/src/FunctionalJavascript/OptionsFieldUIAllowedValuesTest.php \Drupal\Tests\options\FunctionalJavascript\OptionsFieldUIAllowedValuesTest::pressEnterOnElement()

Presses "Enter" on the specified element.

Parameters

string $selector: Current element having focus.

1 call to OptionsFieldUIAllowedValuesTest::pressEnterOnElement()
OptionsFieldUIAllowedValuesTest::testOptionsAllowedValues in core/modules/options/tests/src/FunctionalJavascript/OptionsFieldUIAllowedValuesTest.php
Tests option types allowed values.

File

core/modules/options/tests/src/FunctionalJavascript/OptionsFieldUIAllowedValuesTest.php, line 282

Class

OptionsFieldUIAllowedValuesTest
Tests the Options field allowed values UI functionality.

Namespace

Drupal\Tests\options\FunctionalJavascript

Code

private function pressEnterOnElement(string $selector) : void {
    $javascript = <<<JS
      const element = document.querySelector('{<span class="php-variable">$selector</span>}');
      const event = new KeyboardEvent('keypress', { key: 'Enter', keyCode: 13, bubbles: true });
      element.dispatchEvent(event);
JS;
    $this->getSession()
        ->executeScript($javascript);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.