Skip to content

Instantly share code, notes, and snippets.

@eliza411
Created June 16, 2013 00:01
Show Gist options
  • Save eliza411/5790114 to your computer and use it in GitHub Desktop.
Save eliza411/5790114 to your computer and use it in GitHub Desktop.
Step definition for TinyMCE
/**
* Use for wysiwyg fields.
*
* @When /^I enter "([^"]*)" in the "([^"]*)" text field$/
*/
public function iEnterInTheEditor($text, $field) {
$page = $this->getSession()->getPage();
if ($field == 'Body' ) {
$iframe_selector = '#edit-body-und-0-value_ifr';
} else {
$iframe_selector = '#edit-field-' . str_replace(' ', '_', strtolower($field)) . '-und-0-value_ifr';
}
$iframe = $page->find('css', $iframe_selector);
if(!$iframe) {
return new When("I fill in \"$field\" with \"$text\"");
} else {
$script = "jQuery('iframe$iframe_selector').contents().find('body#tinymce').append('<p>$text</p>')";
$this->getSession()->executeScript($script);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment