MDL-42625 behat: Fixing failures

* Expanding fieldsets before setting the course format
* Ensure editors are loaded moved to expand_all_fieldsets
* Return true rather than false when JS is disabled and
  non-allowed steps should continue without throwing an
  exception.
This commit is contained in:
David Monllao
2013-12-12 13:42:56 +08:00
parent 26f9407892
commit fff8b97ebc
5 changed files with 9 additions and 25 deletions
@@ -16,7 +16,6 @@ Feature: Display extended course names
Scenario: Courses list with extended course names
Given I expand "Site administration" node
And I expand "Appearance" node
And I click on "Courses" "link" in the "//div[@id='settingsnav']/descendant::li[contains(concat(' ', normalize-space(@class), ' '), ' type_setting ')][contains(., 'Appearance')]" "xpath_element"
And I check "Display extended course names"
When I press "Save changes"
+1 -1
View File
@@ -101,7 +101,7 @@ class behat_course extends behat_base {
// Adding a forced wait until editors are loaded as otherwise selenium sometimes tries clicks on the
// format field when the editor is being rendered and the click misses the field coordinates.
$steps[] = new Given('I wait until the editors are loaded');
$steps[] = new Given('I expand all fieldsets');
$steps[] = new Given('I select "' . $formatvalue . '" from "' . $formatfield . '"');
$steps[] = new Given('I fill the moodle form with:', $table);
} else {
+3 -3
View File
@@ -69,9 +69,6 @@ class behat_forms extends behat_base {
*/
public function i_fill_the_moodle_form_with(TableNode $data) {
// We ensure that all the editors are loaded and we can interact with them.
$this->ensure_editors_are_loaded();
// Expand all fields in case we have.
$this->expand_all_fields();
@@ -110,6 +107,9 @@ class behat_forms extends behat_base {
*/
protected function expand_all_fields() {
// We ensure that all the editors are loaded and we can interact with them.
$this->ensure_editors_are_loaded();
// behat_base::find() throws an exception if there are no elements, we should not fail a test because of this.
try {
+3 -18
View File
@@ -77,16 +77,16 @@ class behat_general extends behat_base {
// moodle_page::$periodicrefreshdelay possible values.
if (!$metarefresh = $this->getSession()->getPage()->find('xpath', "//head/descendant::meta[@http-equiv='refresh']")) {
// We don't fail the scenario if no redirection with message is found to avoid race condition false failures.
return false;
return true;
}
// Wrapped in try & catch in case the redirection has already been executed.
try {
$content = $metarefresh->getAttribute('content');
} catch (NoSuchElement $e) {
return false;
return true;
} catch (StaleElementReference $e) {
return false;
return true;
}
// Getting the refresh time and the url if present.
@@ -219,21 +219,6 @@ class behat_general extends behat_base {
$this->getSession()->wait(self::TIMEOUT * 1000, self::PAGE_READY_JS);
}
/**
* Waits until the editors are all completely loaded.
*
* @Given /^I wait until the editors are loaded$/
* @throws DriverException
*/
public function wait_until_editors_are_loaded() {
if (!$this->running_javascript()) {
throw new DriverException('Editors are not loaded when running without Javascript support');
}
$this->ensure_editors_are_loaded();
}
/**
* Waits until the provided element selector exists in the DOM
*
+2 -2
View File
@@ -57,7 +57,7 @@ class behat_navigation extends behat_base {
// Administration menu is not loaded by default any more. Click the link to expand.
return new Given('I click on "'.$nodetext.'" "link" in the "'.get_string('administration').'" "block"');
}
return false;
return true;
}
// Avoid problems with quotes.
@@ -91,7 +91,7 @@ class behat_navigation extends behat_base {
// No collapsible nodes with non-JS browsers.
if (!$this->running_javascript()) {
return false;
return true;
}
// Avoid problems with quotes.