Created
January 17, 2016 21:22
-
-
Save johnennewdeeson/240e2b60c23ea3217887 to your computer and use it in GitHub Desktop.
CKEditor fill in field in a Behat step definition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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\");"); | |
} |
works great, thanks!
You saved my day, thanks :)
Saved my day too :)
When I had to tag my scenario with @javascript my normal line And I fill in "field" with "value"
stopped working. Now it's working fine again thanks to this :)
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
Many thanks for this!