diff --git a/admin/tests/behat/behat_admin.php b/admin/tests/behat/behat_admin.php index 97a78a44477..0cd23064ad4 100644 --- a/admin/tests/behat/behat_admin.php +++ b/admin/tests/behat/behat_admin.php @@ -72,11 +72,11 @@ class behat_admin extends behat_base { // Admin settings does not use the same DOM structure than other moodle forms // but we also need to use lib/behat/form_field/* to deal with the different moodle form elements. $exception = new ElementNotFoundException($this->getSession(), '"' . $label . '" administration setting '); - $fieldxpath = "//*[self::input | self::textarea | self::select][not(./@type = 'submit' or ./@type = 'image' or ./@type = 'hidden')] -[@id=//label[contains(normalize-space(string(.)), '" . $label . "')]/@for]"; + $fieldxpath = "//*[self::input | self::textarea | self::select][not(./@type = 'submit' or ./@type = 'image' or ./@type = 'hidden')]" . + "[@id=//label[contains(normalize-space(string(.)), '" . $label . "')]/@for]"; $fieldnode = $this->find('xpath', $fieldxpath, $exception); - $formfieldtypenode = $this->find('xpath', $fieldxpath . "/ancestor::div[@class='form-setting'] -/child::div[contains(concat(' ', @class, ' '), ' form-')]/child::*/parent::div"); + $formfieldtypenode = $this->find('xpath', $fieldxpath . "/ancestor::div[@class='form-setting']" . + "/child::div[contains(concat(' ', @class, ' '), ' form-')]/child::*/parent::div"); // Getting the class which contains the field type. $classes = explode(' ', $formfieldtypenode->getAttribute('class')); diff --git a/auth/tests/behat/behat_auth.php b/auth/tests/behat/behat_auth.php index eab0062760d..c6d47aa4958 100644 --- a/auth/tests/behat/behat_auth.php +++ b/auth/tests/behat/behat_auth.php @@ -52,8 +52,8 @@ class behat_auth extends behat_base { new Given('I follow "Login"'), new Given('I fill in "Username" with "'.$username.'"'), new Given('I fill in "Password" with "'.$username.'"'), - new When('I press "Login"'), - new Given('I should see "You are logged in as"')); + new Given('I press "Login"') + ); } /** diff --git a/backup/util/ui/tests/behat/behat_backup.php b/backup/util/ui/tests/behat/behat_backup.php index 79c05e126dc..4d8f4b1155b 100644 --- a/backup/util/ui/tests/behat/behat_backup.php +++ b/backup/util/ui/tests/behat/behat_backup.php @@ -112,9 +112,9 @@ class behat_backup extends behat_base { $exception = new ExpectationException('"' . $fromcourse . '" course not found in the list of courses to import from', $this->getSession()); $fromcourse = str_replace("'", "\'", $fromcourse); - $xpath = "//div[contains(concat(' ', @class, ' '), ' ics-results ')] -/descendant::tr[contains(., '" . $fromcourse . "')] -/descendant::input[@type='radio']"; + $xpath = "//div[contains(concat(' ', @class, ' '), ' ics-results ')]" . + "/descendant::tr[contains(., '" . $fromcourse . "')]" . + "/descendant::input[@type='radio']"; $radionode = $this->find('xpath', $xpath, $exception); $radionode->check(); $radionode->click(); @@ -152,10 +152,10 @@ class behat_backup extends behat_base { // Selecting the specified course (we can not call behat_forms::select_radio here as is in another behat subcontext). $existingcourse = str_replace("'", "\'", $existingcourse); - $radionode = $this->find('xpath', "//div[contains(@class, 'bcs-existing-course')] -/descendant::div[@class='restore-course-search'] -/descendant::tr[contains(., '" . $existingcourse . "')] -/descendant::input[@type='radio']"); + $radionode = $this->find('xpath', "//div[contains(@class, 'bcs-existing-course')]" . + "/descendant::div[@class='restore-course-search']" . + "/descendant::tr[contains(., '" . $existingcourse . "')]" . + "/descendant::input[@type='radio']"); $radionode->check(); $radionode->click(); @@ -181,9 +181,9 @@ class behat_backup extends behat_base { $this->select_backup($backupfilename); // The first category in the list. - $radionode = $this->find('xpath', "//div[contains(@class, 'bcs-new-course')] -/descendant::div[@class='restore-course-search'] -/descendant::input[@type='radio']"); + $radionode = $this->find('xpath', "//div[contains(@class, 'bcs-new-course')]" . + "/descendant::div[@class='restore-course-search']" . + "/descendant::input[@type='radio']"); $radionode->check(); $radionode->click(); @@ -209,13 +209,14 @@ class behat_backup extends behat_base { $this->select_backup($backupfilename); // Merge without deleting radio option. - $radionode = $this->find('xpath', "//div[contains(@class, 'bcs-current-course')] -/descendant::input[@type='radio'][@name='target'][@value='1']"); + $radionode = $this->find('xpath', "//div[contains(@class, 'bcs-current-course')]" . + "/descendant::input[@type='radio'][@name='target'][@value='1']"); $radionode->check(); $radionode->click(); // Pressing the continue button of the restore merging section. - $continuenode = $this->find('xpath', "//div[contains(@class, 'bcs-current-course')]/descendant::input[@type='submit'][@value='Continue']"); + $continuenode = $this->find('xpath', "//div[contains(@class, 'bcs-current-course')]" . + "/descendant::input[@type='submit'][@value='Continue']"); $continuenode->click(); $this->wait(); @@ -236,13 +237,14 @@ class behat_backup extends behat_base { $this->select_backup($backupfilename); // Delete contents radio option. - $radionode = $this->find('xpath', "//div[contains(@class, 'bcs-current-course')] -/descendant::input[@type='radio'][@name='target'][@value='0']"); + $radionode = $this->find('xpath', "//div[contains(@class, 'bcs-current-course')]" . + "/descendant::input[@type='radio'][@name='target'][@value='0']"); $radionode->check(); $radionode->click(); // Pressing the continue button of the restore merging section. - $continuenode = $this->find('xpath', "//div[contains(@class, 'bcs-current-course')]/descendant::input[@type='submit'][@value='Continue']"); + $continuenode = $this->find('xpath', "//div[contains(@class, 'bcs-current-course')]" . + "/descendant::input[@type='submit'][@value='Continue']"); $continuenode->click(); $this->wait(); diff --git a/backup/util/ui/tests/behat/restore_moodle2_courses.feature b/backup/util/ui/tests/behat/restore_moodle2_courses.feature index 4e5d4b82fe9..fb6673737d4 100644 --- a/backup/util/ui/tests/behat/restore_moodle2_courses.feature +++ b/backup/util/ui/tests/behat/restore_moodle2_courses.feature @@ -12,7 +12,7 @@ Feature: Restore Moodle 2 course backups And I log in as "admin" And I follow "Course 1" And I turn editing mode on - And I add a "forum" to section "1" and I fill the form with: + And I add a "Forum" to section "1" and I fill the form with: | Forum name | Test forum name | | Description | Test forum description | And I add the "Community finder" block diff --git a/blocks/comments/tests/behat/behat_block_comments.php b/blocks/comments/tests/behat/behat_block_comments.php index 447eb5aaf31..548246062a3 100644 --- a/blocks/comments/tests/behat/behat_block_comments.php +++ b/blocks/comments/tests/behat/behat_block_comments.php @@ -91,8 +91,8 @@ class behat_block_comments extends behat_base { $exception = new ElementNotFoundException($this->getSession(), '"' . $comment . '" comment '); - $commentxpath = "//div[contains(concat(' ', @class, ' '), ' block_comments ')] -/descendant::div[@class='comment-message'][contains(., '" . $comment . "')]"; + $commentxpath = "//div[contains(concat(' ', @class, ' '), ' block_comments ')]" . + "/descendant::div[@class='comment-message'][contains(., '" . $comment . "')]"; $commentnode = $this->find('xpath', $commentxpath, $exception); // Click on delete icon. diff --git a/completion/tests/behat/behat_completion.php b/completion/tests/behat/behat_completion.php index 7bf57fbf481..ef05aeb328d 100644 --- a/completion/tests/behat/behat_completion.php +++ b/completion/tests/behat/behat_completion.php @@ -50,7 +50,8 @@ class behat_completion extends behat_base { public function user_has_completed_activity($userfullname, $activityname) { // Will throw an exception if the element can not be hovered. - $xpath = "//table[@id='completion-progress']/descendant::img[contains(@title, '" . $userfullname . ", " . $activityname . ": Completed')]"; + $xpath = "//table[@id='completion-progress']" . + "/descendant::img[contains(@title, '" . $userfullname . ", " . $activityname . ": Completed')]"; return array( new Given('I go to the current course activity completion report'), @@ -67,7 +68,8 @@ class behat_completion extends behat_base { */ public function user_has_not_completed_activity($userfullname, $activityname) { - $xpath = "//table[@id='completion-progress']/descendant::img[contains(@title, '" . $userfullname . ", " . $activityname . ": Not completed')]"; + $xpath = "//table[@id='completion-progress']" . + "/descendant::img[contains(@title, '" . $userfullname . ", " . $activityname . ": Not completed')]"; return array( new Given('I go to the current course activity completion report'), new Given('I hover "' . $xpath . '" "xpath_element"') @@ -87,7 +89,10 @@ class behat_completion extends behat_base { // Expand reports node if we can't see the link. try { - $this->find('xpath', "//*[@id='settingsnav']/descendant::li/descendant::li[not(contains(@class,'collapsed'))]/descendant::p[contains(., 'Activity completion')]"); + $this->find('xpath', "//*[@id='settingsnav']" . + "/descendant::li" . + "/descendant::li[not(contains(@class,'collapsed'))]" . + "/descendant::p[contains(., 'Activity completion')]"); } catch (ElementNotFoundException $e) { $steps[] = new Given('I expand "Reports" node'); } diff --git a/course/tests/behat/activities_group_icons.feature b/course/tests/behat/activities_group_icons.feature index 82cd3f277c3..d796ab27225 100644 --- a/course/tests/behat/activities_group_icons.feature +++ b/course/tests/behat/activities_group_icons.feature @@ -18,7 +18,7 @@ Feature: Toggle activities groups mode from the course page And I log in as "teacher1" And I follow "Course 1" And I turn editing mode on - And I add a "forum" to section "1" and I fill the form with: + And I add a "Forum" to section "1" and I fill the form with: | Forum name | Test forum name | | Description | Test forum description | And I follow "Edit settings" diff --git a/course/tests/behat/activities_visibility_icons.feature b/course/tests/behat/activities_visibility_icons.feature index 6f6029923a7..6f1fc1faa9a 100644 --- a/course/tests/behat/activities_visibility_icons.feature +++ b/course/tests/behat/activities_visibility_icons.feature @@ -20,7 +20,7 @@ Feature: Toggle activities visibility from the course page And I log in as "teacher1" And I follow "Course 1" And I turn editing mode on - And I add a "forum" to section "1" and I fill the form with: + And I add a "Forum" to section "1" and I fill the form with: | Forum name | Test forum name | | Description | Test forum description | | Visible | Show | diff --git a/course/tests/behat/behat_course.php b/course/tests/behat/behat_course.php index 71a59b901f6..532a4629ff0 100644 --- a/course/tests/behat/behat_course.php +++ b/course/tests/behat/behat_course.php @@ -126,9 +126,9 @@ class behat_course extends behat_base { // Clicks the selected activity if it exists. $activity = ucfirst($activity); - $activityxpath = "//div[@id='chooseform']/descendant::label -/descendant::span[contains(concat(' ', @class, ' '), ' typename ')][contains(.,'" . $activity . "')] -/parent::label/child::input"; + $activityxpath = "//div[@id='chooseform']/descendant::label" . + "/descendant::span[contains(concat(' ', @class, ' '), ' typename ')][contains(.,'" . $activity . "')]" . + "/parent::label/child::input"; $activitynode = $this->find('xpath', $activityxpath); $activitynode->doubleClick(); @@ -136,8 +136,8 @@ class behat_course extends behat_base { // Without Javascript. // Selecting the option from the select box which contains the option. - $selectxpath = $sectionxpath . "/descendant::div[contains(concat(' ', @class, ' '), ' section_add_menus ')] -/descendant::select[contains(., '" . $activity . "')]"; + $selectxpath = $sectionxpath . "/descendant::div[contains(concat(' ', @class, ' '), ' section_add_menus ')]" . + "/descendant::select[contains(., '" . $activity . "')]"; $selectnode = $this->find('xpath', $selectxpath); $selectnode->selectOption($activity); @@ -279,8 +279,8 @@ class behat_course extends behat_base { foreach ($activities as $activity) { // Dimmed. - $this->find('xpath', "//div[contains(concat(' ', @class, ' '), ' activityinstance ')] -/a[contains(concat(' ', @class, ' '), ' dimmed ')]", $dimmedexception, $activity); + $this->find('xpath', "//div[contains(concat(' ', @class, ' '), ' activityinstance ')]" . + "/a[contains(concat(' ', @class, ' '), ' dimmed ')]", $dimmedexception, $activity); // To check that the visibility is not clickable we check the funcionality rather than the applied style. $visibilityiconnode = $this->find('css', 'a.editing_show img', false, $activity); diff --git a/course/tests/behat/force_group_mode.feature b/course/tests/behat/force_group_mode.feature index 8e065814a8d..0389189991f 100644 --- a/course/tests/behat/force_group_mode.feature +++ b/course/tests/behat/force_group_mode.feature @@ -17,7 +17,7 @@ Feature: Force group mode in a course And I log in as "teacher1" And I follow "Course 1" And I turn editing mode on - And I add a "chat" to section "1" and I fill the form with: + And I add a "Chat" to section "1" and I fill the form with: | Name of this chat room | Chat room | | Description | Chat description | And I follow "Edit settings" diff --git a/course/tests/behat/restrict_available_activities.feature b/course/tests/behat/restrict_available_activities.feature index 96be033ec70..9ffa0038927 100644 --- a/course/tests/behat/restrict_available_activities.feature +++ b/course/tests/behat/restrict_available_activities.feature @@ -20,10 +20,10 @@ Feature: Restrict activities availability Given I log in as "teacher1" And I follow "Course 1" And I turn editing mode on - When I add a "glossary" to section "1" and I fill the form with: + When I add a "Glossary" to section "1" and I fill the form with: | Name | Test glossary name | | Description | Test glossary description | - And I add a "chat" to section "1" and I fill the form with: + And I add a "Chat" to section "1" and I fill the form with: | Name of this chat room | Test chat name | | Description | Test chat description | Then I should see "Test glossary name" diff --git a/course/tests/behat/section_visibility.feature b/course/tests/behat/section_visibility.feature index 9a433b3afdb..bef695e9bdf 100644 --- a/course/tests/behat/section_visibility.feature +++ b/course/tests/behat/section_visibility.feature @@ -20,27 +20,27 @@ Feature: Show/hide course sections And I log in as "teacher1" And I follow "Course 1" And I turn editing mode on - And I add a "forum" to section "1" and I fill the form with: + And I add a "Forum" to section "1" and I fill the form with: | Forum name | Test hidden forum 11 name | | Description | Test hidden forum 11 description | | Visible | Hide | - And I add a "forum" to section "1" and I fill the form with: + And I add a "Forum" to section "1" and I fill the form with: | Forum name | Test hidden forum 12 name | | Description | Test hidden forum 12 description | | Visible | Show | - And I add a "forum" to section "2" and I fill the form with: + And I add a "Forum" to section "2" and I fill the form with: | Forum name | Test hidden forum 21 name | | Description | Test hidden forum 21 description | | Visible | Hide | - And I add a "forum" to section "2" and I fill the form with: + And I add a "Forum" to section "2" and I fill the form with: | Forum name | Test hidden forum 22 name | | Description | Test hidden forum 22 description | | Visible | Show | - And I add a "forum" to section "3" and I fill the form with: + And I add a "Forum" to section "3" and I fill the form with: | Forum name | Test hidden forum 31 name | | Description | Test hidden forum 31 description | | Visible | Hide | - And I add a "forum" to section "3" and I fill the form with: + And I add a "Forum" to section "3" and I fill the form with: | Forum name | Test hidden forum 32 name | | Description | Test hidden forum 32 description | | Visible | Show | diff --git a/lib/behat/behat_base.php b/lib/behat/behat_base.php index ece712b6f40..02b968fec30 100644 --- a/lib/behat/behat_base.php +++ b/lib/behat/behat_base.php @@ -411,7 +411,7 @@ class behat_base extends Behat\MinkExtension\Context\RawMinkContext { * @return boolean */ protected function running_javascript() { - return get_class($this->getSession()->getDriver()) === 'Moodle\BehatExtension\Driver\MoodleSelenium2Driver'; + return get_class($this->getSession()->getDriver()) !== 'Behat\Mink\Driver\GoutteDriver'; } } diff --git a/lib/behat/form_field/behat_form_field.php b/lib/behat/form_field/behat_form_field.php index 19340b7d607..dc28e0416f7 100644 --- a/lib/behat/form_field/behat_form_field.php +++ b/lib/behat/form_field/behat_form_field.php @@ -112,7 +112,7 @@ class behat_form_field { global $CFG; // Textareas are considered text based elements. - $tagname = $this->field->getTagName(); + $tagname = strtolower($this->field->getTagName()); if ($tagname == 'textarea') { return false; } @@ -131,11 +131,13 @@ class behat_form_field { default: return false; } - } - // Select tag. - if ($tagname == 'select') { + } else if ($tagname == 'select') { + // Select tag. $classname = 'behat_form_select'; + + } else { + return false; } $classpath = $CFG->dirroot . '/lib/behat/form_field/' . $classname . '.php'; @@ -143,4 +145,13 @@ class behat_form_field { return new $classname($this->session, $this->field); } + /** + * Returns whether the scenario is running in a browser that can run Javascript or not. + * + * @return bool + */ + protected function running_javascript() { + return get_class($this->session->getDriver()) !== 'Behat\Mink\Driver\GoutteDriver'; + } + } diff --git a/lib/behat/form_field/behat_form_select.php b/lib/behat/form_field/behat_form_select.php index 4aa392a51e8..be8a718a19b 100644 --- a/lib/behat/form_field/behat_form_select.php +++ b/lib/behat/form_field/behat_form_select.php @@ -45,6 +45,26 @@ class behat_form_select extends behat_form_field { */ public function set_value($value) { $this->field->selectOption($value); + + // Adding a click as Selenium requires it to fire some JS events. + if ($this->running_javascript()) { + + // Single select needs an extra click in the option. + if (!$this->field->hasAttribute('multiple')) { + // Using the driver direcly because Element methods are messy when dealing + // with elements inside containers. + $optionxpath = $this->field->getXpath() . + "/descendant::option[(./@value = '" . $value . "' or contains(normalize-space(string(.)), '" . $value . "'))]"; + $optionnodes = $this->session->getDriver()->find($optionxpath); + if ($optionnodes) { + current($optionnodes)->click(); + } + + } else { + // Multiple ones needs the click in the select. + $this->field->click(); + } + } } /** diff --git a/lib/tests/behat/behat_forms.php b/lib/tests/behat/behat_forms.php index 57c76ebee8e..46dc5a456d0 100644 --- a/lib/tests/behat/behat_forms.php +++ b/lib/tests/behat/behat_forms.php @@ -132,7 +132,8 @@ class behat_forms extends behat_base { // Show all fields. $showmorestr = get_string('showmore', 'form'); - $showmores = $this->find_all('xpath', "//a[contains(concat(' ', normalize-space(.), ' '), '" . $showmorestr . "')][contains(concat(' ', normalize-space(@class), ' '), ' moreless-toggler')]"); + $showmores = $this->find_all('xpath', "//a[contains(concat(' ', normalize-space(.), ' '), '" . $showmorestr . "')]" . + "[contains(concat(' ', normalize-space(@class), ' '), ' moreless-toggler')]"); // We are supposed to have 'show more's here, otherwise exception. @@ -177,7 +178,16 @@ class behat_forms extends behat_base { // Adding a click as Selenium requires it to fire some JS events. if ($this->running_javascript()) { - $selectnode->click(); + + if (!$selectnode->hasAttribute('multiple')) { + // Single select needs an extra click in the option. + $xpath = ".//option[(./@value = '" . $option . "' or contains(normalize-space(string(.)), '" . $option . "'))]"; + $optionnode = $this->find('xpath', $xpath, false, $selectnode); + $optionnode->click(); + } else { + // Multiple ones needs the click in the select. + $selectnode->click(); + } } } diff --git a/lib/tests/behat/behat_hooks.php b/lib/tests/behat/behat_hooks.php index 4fb968e5e93..5b934b249db 100644 --- a/lib/tests/behat/behat_hooks.php +++ b/lib/tests/behat/behat_hooks.php @@ -150,7 +150,7 @@ class behat_hooks extends behat_base { // Just trying if server responds. try { - $this->getSession()->executeScript('// empty comment'); + $this->getSession()->wait(0, false); } catch (Exception $e) { $moreinfo = 'More info in ' . behat_command::DOCS_URL . '#Running_tests'; $msg = 'Selenium server is not running, you need to start it to run tests that involves Javascript. ' . $moreinfo; @@ -173,9 +173,22 @@ class behat_hooks extends behat_base { return; } - // Wait until the page is ready. - try { - $this->getSession()->wait(self::TIMEOUT, '(document.readyState === "complete")'); + // Wait until the page is ready. + // We are already checking that we use a JS browser, this could + // change in case we use another JS driver. + try { + + // Safari and Internet Explorer requires time between steps, + // otherwise Selenium tries to click in the previous page's DOM. + if ($this->getSession()->getDriver()->getBrowserName() == 'safari' || + $this->getSession()->getDriver()->getBrowserName() == 'internet explorer') { + $this->getSession()->wait(self::TIMEOUT * 1000, false); + + } else { + // With other browsers we just wait for the DOM ready. + $this->getSession()->wait(self::TIMEOUT * 1000, '(document.readyState === "complete")'); + } + } catch (NoSuchWindow $e) { // If we were interacting with a popup window it will not exists after closing it. } diff --git a/lib/tests/behat/behat_navigation.php b/lib/tests/behat/behat_navigation.php index f3bad4610ba..9146eb9593f 100644 --- a/lib/tests/behat/behat_navigation.php +++ b/lib/tests/behat/behat_navigation.php @@ -53,17 +53,16 @@ class behat_navigation extends behat_base { return false; } - $xpath = "//ul[contains(concat(' ', normalize-space(@class), ' '), ' block_tree ')] -/child::li -/child::p[contains(concat(' ', normalize-space(@class), ' '), ' branch')] -/child::span[contains(concat(' ', normalize-space(.), ' '), '" . $nodetext . "')] -| -//ul[contains(concat(' ', normalize-space(@class), ' '), ' block_tree ')] -/descendant::li[not(contains(concat(' ', normalize-space(@class), ' '), ' collapsed'))] -/descendant::li -/child::p[contains(concat(' ', normalize-space(@class), ' '), ' branch')] -/child::span[contains(concat(' ', normalize-space(.), ' '), '" . $nodetext . "')] -"; + $xpath = "//ul[contains(concat(' ', normalize-space(@class), ' '), ' block_tree ')]" . + "/child::li" . + "/child::p[contains(concat(' ', normalize-space(@class), ' '), ' branch')]" . + "/child::span[contains(concat(' ', normalize-space(.), ' '), '" . $nodetext . "')]" . + "|" . + "//ul[contains(concat(' ', normalize-space(@class), ' '), ' block_tree ')]" . + "/descendant::li[not(contains(concat(' ', normalize-space(@class), ' '), ' collapsed'))]" . + "/descendant::li" . + "/child::p[contains(concat(' ', normalize-space(@class), ' '), ' branch')]" . + "/child::span[contains(concat(' ', normalize-space(.), ' '), '" . $nodetext . "')]"; $node = $this->find('xpath', $xpath); $node->click(); diff --git a/mod/choice/tests/behat/add_choice.feature b/mod/choice/tests/behat/add_choice.feature index 848dc9366ae..c6e806ef8fa 100644 --- a/mod/choice/tests/behat/add_choice.feature +++ b/mod/choice/tests/behat/add_choice.feature @@ -20,7 +20,7 @@ Feature: Add choice activity And I log in as "teacher1" And I follow "Course 1" And I turn editing mode on - And I add a "choice" to section "1" and I fill the form with: + And I add a "Choice" to section "1" and I fill the form with: | Choice name | Choice name | | Description | Choice Description | | option[0] | Option 1 | diff --git a/mod/choice/tests/behat/publish_results.feature b/mod/choice/tests/behat/publish_results.feature index cbf4309eeef..8f937cf71be 100644 --- a/mod/choice/tests/behat/publish_results.feature +++ b/mod/choice/tests/behat/publish_results.feature @@ -22,7 +22,7 @@ Feature: A teacher can choose one of 4 options for publishing choice results @javascript Scenario: Do not publish results to students - Given I add a "choice" to section "1" and I fill the form with: + Given I add a "Choice" to section "1" and I fill the form with: | Choice name | Choice 1 | | Description | Choice Description | | Publish results | Do not publish results to students | @@ -38,7 +38,7 @@ Feature: A teacher can choose one of 4 options for publishing choice results @javascript Scenario: Show results to students after they answer - Given I add a "choice" to section "1" and I fill the form with: + Given I add a "Choice" to section "1" and I fill the form with: | Choice name | Choice 1 | | Description | Choice Description | | option[0] | Option 1 | @@ -58,7 +58,7 @@ Feature: A teacher can choose one of 4 options for publishing choice results @javascript Scenario: Show results to students only after the choice is closed - Given I add a "choice" to section "1" and I fill the form with: + Given I add a "Choice" to section "1" and I fill the form with: | Choice name | Choice 1 | | Description | Choice Description | | Publish results | Show results to students only after the choice is closed | @@ -90,7 +90,7 @@ Feature: A teacher can choose one of 4 options for publishing choice results @javascript Scenario: Always show results to students - Given I add a "choice" to section "1" and I fill the form with: + Given I add a "Choice" to section "1" and I fill the form with: | Choice name | Choice 1 | | Description | Choice Description | | option[0] | Option 1 | diff --git a/mod/choice/tests/behat/publish_results_anonymously.feature b/mod/choice/tests/behat/publish_results_anonymously.feature index aa31519604d..af0690ed8bf 100644 --- a/mod/choice/tests/behat/publish_results_anonymously.feature +++ b/mod/choice/tests/behat/publish_results_anonymously.feature @@ -24,7 +24,7 @@ Feature: A teacher can choose whether to publish choice activity results anonymo @javascript Scenario: Publish anonymous results - Given I add a "choice" to section "1" and I fill the form with: + Given I add a "Choice" to section "1" and I fill the form with: | Choice name | Choice 1 | | Description | Choice Description | | option[0] | Option 1 | @@ -45,7 +45,7 @@ Feature: A teacher can choose whether to publish choice activity results anonymo @javascript Scenario: Publish full results - Given I add a "choice" to section "1" and I fill the form with: + Given I add a "Choice" to section "1" and I fill the form with: | Choice name | Choice 1 | | Description | Choice Description | | option[0] | Option 1 | diff --git a/mod/forum/tests/behat/add_forum.feature b/mod/forum/tests/behat/add_forum.feature index 11357e03b53..2eaf6c5a1cc 100644 --- a/mod/forum/tests/behat/add_forum.feature +++ b/mod/forum/tests/behat/add_forum.feature @@ -18,7 +18,7 @@ Feature: Add forum activities and discussions And I log in as "teacher1" And I follow "Course 1" And I turn editing mode on - And I add a "forum" to section "1" and I fill the form with: + And I add a "Forum" to section "1" and I fill the form with: | Forum name | Test forum name | | Forum type | Standard forum for general use | | Description | Test forum description | diff --git a/mod/forum/tests/behat/discussion_display.feature b/mod/forum/tests/behat/discussion_display.feature index fb9d64541ff..11dc57ecb98 100644 --- a/mod/forum/tests/behat/discussion_display.feature +++ b/mod/forum/tests/behat/discussion_display.feature @@ -17,7 +17,7 @@ Feature: Students can choose from 4 discussion display options and their choice And I log in as "admin" And I follow "Course 1" And I turn editing mode on - And I add a "forum" to section "1" and I fill the form with: + And I add a "Forum" to section "1" and I fill the form with: | Forum name | Test forum name | | Description | Test forum description | And I add a new discussion to "Test forum name" forum with: diff --git a/mod/forum/tests/behat/edit_post_student.feature b/mod/forum/tests/behat/edit_post_student.feature index 86e20f51e9e..f644569d455 100644 --- a/mod/forum/tests/behat/edit_post_student.feature +++ b/mod/forum/tests/behat/edit_post_student.feature @@ -23,7 +23,7 @@ Feature: Students can edit or delete their forum posts within a set time limit And I am on homepage And I follow "Course 1" And I turn editing mode on - And I add a "forum" to section "1" and I fill the form with: + And I add a "Forum" to section "1" and I fill the form with: | Forum name | Test forum name | | Forum type | Standard forum for general use | | Description | Test forum description | diff --git a/mod/forum/tests/behat/edit_post_teacher.feature b/mod/forum/tests/behat/edit_post_teacher.feature index 27ecb49ba81..6af33cbccf3 100644 --- a/mod/forum/tests/behat/edit_post_teacher.feature +++ b/mod/forum/tests/behat/edit_post_teacher.feature @@ -19,7 +19,7 @@ Feature: Teachers can edit or delete any forum post And I log in as "teacher1" And I follow "Course 1" And I turn editing mode on - And I add a "forum" to section "1" and I fill the form with: + And I add a "Forum" to section "1" and I fill the form with: | Forum name | Test forum name | | Description | Test forum description | And I add a new discussion to "Test forum name" forum with: diff --git a/mod/forum/tests/behat/single_forum_discussion.feature b/mod/forum/tests/behat/single_forum_discussion.feature index dcc7674259e..818c1765ff9 100644 --- a/mod/forum/tests/behat/single_forum_discussion.feature +++ b/mod/forum/tests/behat/single_forum_discussion.feature @@ -19,7 +19,7 @@ Feature: Single simple forum discussion type And I log in as "teacher1" And I follow "Course 1" And I turn editing mode on - And I add a "forum" to section "1" and I fill the form with: + And I add a "Forum" to section "1" and I fill the form with: | Forum name | Single discussion forum name | | Forum type | A single simple discussion | | Description | Single discussion forum description | diff --git a/mod/forum/tests/behat/track_read_posts.feature b/mod/forum/tests/behat/track_read_posts.feature index 01d5a40bfd4..6b8ab559da3 100644 --- a/mod/forum/tests/behat/track_read_posts.feature +++ b/mod/forum/tests/behat/track_read_posts.feature @@ -20,7 +20,7 @@ Feature: A teacher can set one of 3 possible options for tracking read forum pos @javascript Scenario: Tracking forum posts on - Given I add a "forum" to section "1" and I fill the form with: + Given I add a "Forum" to section "1" and I fill the form with: | Forum name | Test forum name | | Forum type | Standard forum for general use | | Description | Test forum description | @@ -41,7 +41,7 @@ Feature: A teacher can set one of 3 possible options for tracking read forum pos @javascript Scenario: Tracking forum posts off - Given I add a "forum" to section "1" and I fill the form with: + Given I add a "Forum" to section "1" and I fill the form with: | Forum name | Test forum name | | Forum type | Standard forum for general use | | Description | Test forum description | @@ -59,7 +59,7 @@ Feature: A teacher can set one of 3 possible options for tracking read forum pos @javascript Scenario: Tracking forum posts optional - Given I add a "forum" to section "1" and I fill the form with: + Given I add a "Forum" to section "1" and I fill the form with: | Forum name | Test forum name | | Forum type | Standard forum for general use | | Description | Test forum description | diff --git a/question/tests/behat/behat_question.php b/question/tests/behat/behat_question.php index fe6daafdc8a..79fe0ea34ae 100644 --- a/question/tests/behat/behat_question.php +++ b/question/tests/behat/behat_question.php @@ -51,8 +51,8 @@ class behat_question extends behat_base { */ public function i_add_a_question_filling_the_form_with($questiontypename, TableNode $questiondata) { - $questiontypexpath = "//span[@class='qtypename'][.='" . $questiontypename . "'] -/ancestor::div[@class='qtypeoption']/descendant::input"; + $questiontypexpath = "//span[@class='qtypename'][.='" . $questiontypename . "']" . + "/ancestor::div[@class='qtypeoption']/descendant::input"; return array( new Given('I follow "' . get_string('questionbank', 'question') . '"'), @@ -81,8 +81,8 @@ class behat_question extends behat_base { $this->find('xpath', $questionxpath, $exception); $exception = new ExpectationException('Question "' . $questiondescription . '" state is not "' . $state . '"', $this->getSession()); - $xpath = $questionxpath . "/ancestor::div[contains(concat(' ', @class, ' '), ' que ')] -/descendant::div[@class='state'][contains(., '" . $state . "')]"; + $xpath = $questionxpath . "/ancestor::div[contains(concat(' ', @class, ' '), ' que ')]" . + "/descendant::div[@class='state'][contains(., '" . $state . "')]"; $this->find('xpath', $xpath, $exception); } diff --git a/repository/tests/behat/behat_filepicker.php b/repository/tests/behat/behat_filepicker.php index 10c9b3f0241..8b83ae3ecaf 100644 --- a/repository/tests/behat/behat_filepicker.php +++ b/repository/tests/behat/behat_filepicker.php @@ -92,8 +92,8 @@ class behat_filepicker extends behat_files { // In the current folder workspace. $folder = $this->find( 'xpath', - "//div[contains(concat(' ', normalize-space(@class), ' '), ' fp-folder ')] -//descendant::div[contains(concat(' ', normalize-space(.), ' '), '" . $foldername . "')]", + "//div[contains(concat(' ', normalize-space(@class), ' '), ' fp-folder ')]" . + "//descendant::div[contains(concat(' ', normalize-space(.), ' '), '" . $foldername . "')]", $exception, $fieldnode ); @@ -102,8 +102,8 @@ class behat_filepicker extends behat_files { // And in the pathbar. $folder = $this->find( 'xpath', - "//a[contains(concat(' ', normalize-space(@class), ' '), ' fp-path-folder-name ')] -[contains(concat(' ', normalize-space(.), ' '), '" . $foldername . "')]", + "//a[contains(concat(' ', normalize-space(@class), ' '), ' fp-path-folder-name ')]" . + "[contains(concat(' ', normalize-space(.), ' '), '" . $foldername . "')]", $exception, $fieldnode );