MDL-43757 behat: Allowing the form field guesser to detect TinyMCE

It includes 2 more minor fixes:
- Escapes values sent to TinyMCE as it was breaking
  when values contained double quotes.
- Adding seconds to the screenshots directory to
  avoid using the same folder for multiple runs.
This commit is contained in:
David Monllao
2014-01-24 15:19:31 +08:00
parent e456f9d65d
commit fa6a33af90
2 changed files with 16 additions and 3 deletions
@@ -52,6 +52,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();
+15 -3
View File
@@ -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':