public function VarbaseContext::prependTheRichTextEditorField in Varbase: The Ultimate Drupal CMS Starter Kit (Bootstrap Ready) 8.8
Same name and namespace in other branches
- 8.4 tests/features/bootstrap/VarbaseContext.php \VarbaseContext::prependTheRichTextEditorField()
- 8.5 tests/features/bootstrap/VarbaseContext.php \VarbaseContext::prependTheRichTextEditorField()
- 8.6 tests/features/bootstrap/VarbaseContext.php \VarbaseContext::prependTheRichTextEditorField()
- 8.7 tests/features/bootstrap/VarbaseContext.php \VarbaseContext::prependTheRichTextEditorField()
- 9.0.x tests/features/bootstrap/VarbaseContext.php \VarbaseContext::prependTheRichTextEditorField()
Add append text at the end of rich text editor field WYSIWYG with content.
Using the name of the field. Varbase Context #varbase.
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 593
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());");
}