Skip to content

Instantly share code, notes, and snippets.

@johnennewdeeson
Created January 17, 2016 21:22
Show Gist options
  • Save johnennewdeeson/240e2b60c23ea3217887 to your computer and use it in GitHub Desktop.
Save johnennewdeeson/240e2b60c23ea3217887 to your computer and use it in GitHub Desktop.
CKEditor fill in field in a Behat step definition
/**
* @Then I fill in wysiwyg on field :locator with :value
*/
public function iFillInWysiwygOnFieldWith($locator, $value) {
$el = $this->getSession()->getPage()->findField($locator);
if (empty($el)) {
throw new ExpectationException('Could not find WYSIWYG with locator: ' . $locator, $this->getSession());
}
$fieldId = $el->getAttribute('id');
if (empty($fieldId)) {
throw new Exception('Could not find an id for field with locator: ' . $locator);
}
$this->getSession()
->executeScript("CKEDITOR.instances[\"$fieldId\"].setData(\"$value\");");
}
@francebenoit
Copy link

francebenoit commented Oct 28, 2021

Thanks a lot ! Still useful 6 years later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment