Beispiel #1
0
 /**
  * Sets the value to a field.
  *
  * @param string $value
  * @return void
  */
 public function set_value($value)
 {
     $lastexception = null;
     // We want the editor to be ready, otherwise the value can not
     // be set and an exception is thrown.
     for ($i = 0; $i < behat_base::EXTENDED_TIMEOUT; $i++) {
         try {
             // Get tinyMCE editor id if it exists.
             if ($editorid = $this->get_editor_id()) {
                 // Set the value to the iframe and save it to the textarea.
                 $this->session->executeScript('
                     tinyMCE.get("' . $editorid . '").setContent("' . $value . '");
                     tinyMCE.get("' . $editorid . '").save();
                 ');
             } else {
                 // Set the value to a textarea otherwise.
                 parent::set_value($value);
             }
             return;
         } catch (Exception $e) {
             // Catching any kind of exception and ignoring it until times out.
             $lastexception = $e;
             // Waiting 0.1 seconds.
             usleep(100000);
         }
     }
     // If it is not available we throw the last exception.
     throw $lastexception;
 }
 /**
  * Sets the value to a field.
  *
  * @param string $value
  * @return void
  */
 public function set_value($value)
 {
     // Get tinyMCE editor id if it exists.
     if ($editorid = $this->get_editor_id()) {
         // Set the value to the iframe and save it to the textarea.
         $this->session->executeScript('
             tinyMCE.get("' . $editorid . '").setContent("' . $value . '");
             tinyMCE.get("' . $editorid . '").save();
         ');
     } else {
         // Set the value to a textarea otherwise.
         parent::set_value($value);
     }
 }
Beispiel #3
0
 /**
  * Sets the value to a field.
  *
  * @param string $value
  * @return void
  */
 public function set_value($value)
 {
     // If tinyMCE var exists means that we are using that editor.
     if ($this->is_editor_available()) {
         // Set the value to the iframe and save it to the textarea.
         $editorid = $this->field->getAttribute('id');
         $this->session->executeScript('
             tinyMCE.get("' . $editorid . '").setContent("' . $value . '");
             tinyMCE.get("' . $editorid . '").save();
         ');
     } else {
         // Set the value to a textarea otherwise.
         parent::set_value($value);
     }
 }
 /**
  * Imports the specified origin course into the other course using the provided options.
  *
  * Keeping it separatelly from backup & restore, it the number of
  * steps and duplicate code becomes bigger a common method should
  * be generalized.
  *
  * @Given /^I import "(?P<from_course_fullname_string>(?:[^"]|\\")*)" course into "(?P<to_course_fullname_string>(?:[^"]|\\")*)" course using this options:$/
  * @param string $fromcourse
  * @param string $tocourse
  * @param TableNode $options
  */
 public function i_import_course_into_course($fromcourse, $tocourse, $options = false)
 {
     // We can not use other steps here as we don't know where the provided data
     // table elements are used, and we need to catch exceptions contantly.
     // Go to homepage.
     $this->getSession()->visit($this->locate_path('/?redirect=0'));
     $this->execute("behat_general::wait_until_the_page_is_ready");
     // Click the course link.
     $this->execute("behat_general::click_link", $tocourse);
     // Click the import link.
     $this->execute("behat_navigation::i_navigate_to_in_current_page_administration", get_string('import'));
     // Select the course.
     $exception = new ExpectationException('"' . $fromcourse . '" course not found in the list of courses to import from', $this->getSession());
     // The argument should be converted to an xpath literal.
     $fromcourse = behat_context_helper::escape($fromcourse);
     $xpath = "//div[contains(concat(' ', normalize-space(@class), ' '), ' ics-results ')]" . "/descendant::tr[contains(., {$fromcourse})]" . "/descendant::input[@type='radio']";
     $radionode = $this->find('xpath', $xpath, $exception);
     $radiofield = new behat_form_field($this->getSession(), $radionode);
     $radiofield->set_value(1);
     $this->execute("behat_forms::press_button", get_string('continue'));
     // Initial settings.
     $this->fill_backup_restore_form($this->get_step_options($options, "Initial"));
     $this->execute("behat_forms::press_button", get_string('importbackupstage1action', 'backup'));
     // Schema settings.
     $this->fill_backup_restore_form($this->get_step_options($options, "Schema"));
     $this->execute("behat_forms::press_button", get_string('importbackupstage2action', 'backup'));
     // Run it.
     $this->execute("behat_forms::press_button", get_string('importbackupstage4action', 'backup'));
     // Wait to ensure restore is complete.
     $this->execute("behat_general::wait_until_the_page_is_ready");
     // Continue and redirect to 'to' course.
     $this->execute("behat_general::i_click_on", array(get_string('continue'), 'button'));
 }
Beispiel #5
0
 /**
  * Imports the specified origin course into the other course using the provided options.
  *
  * Keeping it separatelly from backup & restore, it the number of
  * steps and duplicate code becomes bigger a common method should
  * be generalized.
  *
  * @Given /^I import "(?P<from_course_fullname_string>(?:[^"]|\\")*)" course into "(?P<to_course_fullname_string>(?:[^"]|\\")*)" course using this options:$/
  * @param string $fromcourse
  * @param string $tocourse
  * @param TableNode $options
  */
 public function i_import_course_into_course($fromcourse, $tocourse, $options = false)
 {
     // We can not use other steps here as we don't know where the provided data
     // table elements are used, and we need to catch exceptions contantly.
     // Go to homepage.
     $this->getSession()->visit($this->locate_path('/?redirect=0'));
     $this->wait();
     // Click the course link.
     $this->find_link($tocourse)->click();
     $this->wait();
     // Click the import link.
     $this->navigate_to_course_settings_link('import');
     $this->wait();
     // Select the course.
     $exception = new ExpectationException('"' . $fromcourse . '" course not found in the list of courses to import from', $this->getSession());
     // The argument should be converted to an xpath literal.
     $fromcourse = $this->getSession()->getSelectorsHandler()->xpathLiteral($fromcourse);
     $xpath = "//div[contains(concat(' ', normalize-space(@class), ' '), ' ics-results ')]" . "/descendant::tr[contains(., {$fromcourse})]" . "/descendant::input[@type='radio']";
     $radionode = $this->find('xpath', $xpath, $exception);
     $radiofield = new behat_form_field($this->getSession(), $radionode);
     $radiofield->set_value(1);
     $this->find_button(get_string('continue'))->press();
     $this->wait();
     // Initial settings.
     $this->fill_backup_restore_form($this->get_step_options($options, "Initial"));
     $this->find_button(get_string('importbackupstage1action', 'backup'))->press();
     $this->wait();
     // Schema settings.
     $this->fill_backup_restore_form($this->get_step_options($options, "Schema"));
     $this->find_button(get_string('importbackupstage2action', 'backup'))->press();
     $this->wait();
     // Run it.
     $this->find_button(get_string('importbackupstage4action', 'backup'))->press();
     $this->wait(self::EXTENDED_TIMEOUT);
     // Continue and redirect to 'to' course.
     $this->find_button(get_string('continue'))->press();
 }