Skip to content

Instantly share code, notes, and snippets.

@jonathanfranks
Created August 12, 2015 15:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonathanfranks/fbe26a75704cfa5846f8 to your computer and use it in GitHub Desktop.
Save jonathanfranks/fbe26a75704cfa5846f8 to your computer and use it in GitHub Desktop.
Behat CKEditor
/**
* @Then /^I fill in wysiwyg field "([^"]*)" with "([^"]*)"$/
*/
public function iFillInWysiwygOnFieldWith($locator, $value) {
$el = $this->getSession()->getPage()->findField($locator);
$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\");");
}
@fchris82
Copy link

fchris82 commented Nov 3, 2015

Maybe you have to use the addslashes() with $value.

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