You are here

function SelectorsContext::moveFocusToField in Varbase: The Ultimate Drupal CMS Starter Kit (Bootstrap Ready) 8.4

Same name and namespace in other branches
  1. 8.8 tests/features/bootstrap/SelectorsContext.php \SelectorsContext::moveFocusToField()
  2. 8.5 tests/features/bootstrap/SelectorsContext.php \SelectorsContext::moveFocusToField()
  3. 8.6 tests/features/bootstrap/SelectorsContext.php \SelectorsContext::moveFocusToField()
  4. 8.7 tests/features/bootstrap/SelectorsContext.php \SelectorsContext::moveFocusToField()
  5. 9.0.x tests/features/bootstrap/SelectorsContext.php \SelectorsContext::moveFocusToField()

#vardot : Move the focus to selected field input element.

Example #1: When I move focus to "Title" field Example #2: And I move focus to "Body" field.

@When /^(?:|I )move focus to "(?P<selectedField>[^"]*)" field$/

File

tests/features/bootstrap/SelectorsContext.php, line 300

Class

SelectorsContext
Defines application features from the specific context.

Code

function moveFocusToField($selectedField) {
  $field = $this
    ->getSession()
    ->getPage()
    ->findField($selectedField);
  $fieldid = $field
    ->getAttribute('id');
  $this
    ->getSession()
    ->getDriver()
    ->evaluateScript("jQuery('#{$fieldid}').focus();");
}