diff --git a/lib/behat/form_field/behat_form_editor.php b/lib/behat/form_field/behat_form_editor.php index 5773d127368..4f100ac1f10 100644 --- a/lib/behat/form_field/behat_form_editor.php +++ b/lib/behat/form_field/behat_form_editor.php @@ -58,6 +58,7 @@ class behat_form_editor extends behat_form_field { if ($editorid = $this->get_editor_id()) { // Set the value to the iframe and save it to the textarea. + $value = str_replace('"', '\"', $value); $this->session->executeScript(' tinyMCE.get("'.$editorid.'").setContent("' . $value . '"); tinyMCE.get("'.$editorid.'").save(); diff --git a/lib/behat/form_field/behat_form_field.php b/lib/behat/form_field/behat_form_field.php index 8db45793c39..284befd3be5 100644 --- a/lib/behat/form_field/behat_form_field.php +++ b/lib/behat/form_field/behat_form_field.php @@ -114,10 +114,22 @@ class behat_form_field { // Textareas are considered text based elements. $tagname = strtolower($this->field->getTagName()); if ($tagname == 'textarea') { - return false; - } - if ($tagname == 'input') { + if (!$this->running_javascript()) { + return false; + } + + // If there is an iframe with $id + _ifr there a TinyMCE editor loaded. + $xpath = '//iframe[@id="' . $this->field->getAttribute('id') . '_ifr"]'; + if (!$this->session->getPage()->find('xpath', $xpath)) { + + // Generic one if it is a normal textarea. + return false; + } + + $classname = 'behat_form_editor'; + + } else if ($tagname == 'input') { $type = $this->field->getAttribute('type'); switch ($type) { case 'text': diff --git a/lib/tests/behat/behat_hooks.php b/lib/tests/behat/behat_hooks.php index 23981bff84a..31f621ddc65 100644 --- a/lib/tests/behat/behat_hooks.php +++ b/lib/tests/behat/behat_hooks.php @@ -321,7 +321,7 @@ class behat_hooks extends behat_base { // All the run screenshots in the same parent dir. if (!$screenshotsdirname = self::get_run_screenshots_dir()) { - $screenshotsdirname = self::$screenshotsdirname = date('Ymd_Hi'); + $screenshotsdirname = self::$screenshotsdirname = date('Ymd_His'); $dir = $CFG->behat_screenshots_path . DIRECTORY_SEPARATOR . $screenshotsdirname;