You are here

function VarbaseContext::selectAllTextInTheRichTextEditorField in Varbase: The Ultimate Drupal CMS Starter Kit (Bootstrap Ready) 8.7

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

#vardot : Select all text in selected field input element.

Example #1: When I select all text in "Body" field Example #2: And I select all text in "Body" field

@When /^(?:|I )select all text in "(?P<selectedField>[^"]*)" rich text editor field$/

File

tests/features/bootstrap/VarbaseContext.php, line 575

Class

VarbaseContext
Defines application features from the specific context.

Code

function selectAllTextInTheRichTextEditorField($selectedField) {
  $el = $this
    ->getSession()
    ->getPage()
    ->findField($selectedField);
  $fieldid = $el
    ->getAttribute('id');
  if (empty($fieldid)) {
    throw new Exception('Could not find an id for the rich text editor field : ' . $selectedField);
  }
  $this
    ->getSession()
    ->getDriver()
    ->evaluateScript("CKEDITOR.instances[\"{$fieldid}\"].execCommand('selectAll', false, null);");
  $this
    ->getSession()
    ->getDriver()
    ->evaluateScript("CKEDITOR.instances[\"{$fieldid}\"].forceNextSelectionCheck();");
  $this
    ->getSession()
    ->getDriver()
    ->evaluateScript("CKEDITOR.instances[\"{$fieldid}\"].selectionChange();");
}