You are here

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

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

#varbase : To fill in a rich text editor field WYSIWYG with content using the name of the field.

Example: When I fill in the rich text editor field "Body" with "Test Body text"

@When /^I fill in the rich text editor field "([^"]*)" with "([^"]*)"$/

File

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

Class

VarbaseContext
Defines application features from the specific context.

Code

public function iFillInTheRichTextEditorField($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}\");");
}