You are here

public function VarbaseContext::prependTheRichTextEditorField in Varbase: The Ultimate Drupal CMS Starter Kit (Bootstrap Ready) 8.6

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

#varbase : To add append text at the end of a rich text editor field WYSIWYG with content using the name of the field.

Example #1: When I prepend before the rich text editor field "Body" with "Test Body text" Example #2: When I prepend the rich text editor field "Body" with "Test Body text"

@When /^(?:|I )prepend(?:| before) the rich text editor field "([^"]*)" with "([^"]*)"$/

File

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

Class

VarbaseContext
Defines application features from the specific context.

Code

public function prependTheRichTextEditorField($locator, $value) {
  $el = $this
    ->getSession()
    ->getPage()
    ->findField($locator);
  $fieldId = $el
    ->getAttribute('id');
  if ($fieldId == NULL) {

    // If the WYSIWYG is in an ifream with no id.
    $iFreamID = $this
      ->_getAttributeByOtherAttributeValue('id', 'title', "Rich Text Editor, " . $el
      ->getAttribute('id'), 'iframe');
    if (!empty($iFreamID)) {
      $fieldId = $iFreamID;
    }
  }
  if (empty($fieldId)) {
    throw new Exception('Could not find an id for the rich text editor field : ' . $locator);
  }
  $this
    ->getSession()
    ->executeScript("CKEDITOR.instances[\"{$fieldId}\"].setData(\"{$value}\"+CKEDITOR.instances[\"{$fieldId}\"].getData());");
}