From bf4c3ee0ffc71747e1462c3cbca22fbc56a5a203 Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Fri, 19 Jun 2015 11:56:52 +0800 Subject: [PATCH 1/2] MDL-50481 behat: Press go button for given single select in non-js For non-js mode, ensure we press the go button for the specified single select, as there can be multiple single selects on the page with go button --- lib/tests/behat/behat_forms.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/tests/behat/behat_forms.php b/lib/tests/behat/behat_forms.php index 22628a422b6..5b3378cacc2 100644 --- a/lib/tests/behat/behat_forms.php +++ b/lib/tests/behat/behat_forms.php @@ -394,7 +394,12 @@ class behat_forms extends behat_base { ); if (!$this->running_javascript()) { - $actions[] = new Given('I press "' . get_string('go') . '"'); + // Press button in the specified select container. + $containerxpath = "//div[contains(concat(' ', normalize-space(@class), ' '), ' singleselect ') and " . + ".//label[contains(normalize-space(string(.)), '" . $singleselect . "')]]"; + + $actions[] = new Given('I click on "' . get_string('go') . '" "button" in the "' . $containerxpath . + '" "xpath_element"'); } return $actions; From 77f1778c40806e9b3603e957e7425eb8fff96d90 Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Fri, 19 Jun 2015 11:59:17 +0800 Subject: [PATCH 2/2] MDL-50481 core_grades: Fixed behat feature and step to work with non-js xPath used in step is not using proper oring and fails with goutee driver. Also, feature don't really need to be executed in js, so setting that as non-js --- grade/tests/behat/behat_grade.php | 12 ++++++++---- grade/tests/behat/grade_minmax.feature | 1 - 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/grade/tests/behat/behat_grade.php b/grade/tests/behat/behat_grade.php index 5b5ed8159c0..3408f71ccd6 100644 --- a/grade/tests/behat/behat_grade.php +++ b/grade/tests/behat/behat_grade.php @@ -107,7 +107,9 @@ class behat_grade extends behat_base { $steps[] = new Given('I click on "' . $this->escape($linkxpath) . '" "xpath_element"'); // After adding id numbers we should wait until the page is reloaded. - $steps[] = new Given('I wait until the page is ready'); + if ($this->running_javascript()) { + $steps[] = new Given('I wait until the page is ready'); + } // Mapping names to idnumbers. $datahash = $data->getRowsHash(); @@ -116,8 +118,8 @@ class behat_grade extends behat_base { // Grrr, we can't equal in categoryitem and courseitem because there is a line jump... $inputxpath ="//input[@class='idnumber'][" . "parent::li[@class='item'][text()='" . $gradeitem . "']" . - " | " . - "parent::li[@class='categoryitem' | @class='courseitem']/parent::ul/parent::li[starts-with(text(),'" . $gradeitem . "')]" . + " or " . + "parent::li[@class='categoryitem' or @class='courseitem']/parent::ul/parent::li[starts-with(text(),'" . $gradeitem . "')]" . "]"; $steps[] = new Given('I set the field with xpath "' . $inputxpath . '" to "' . $idnumber . '"'); } @@ -125,7 +127,9 @@ class behat_grade extends behat_base { $steps[] = new Given('I press "' . get_string('addidnumbers', 'grades') . '"'); // After adding id numbers we should wait until the page is reloaded. - $steps[] = new Given('I wait until the page is ready'); + if ($this->running_javascript()) { + $steps[] = new Given('I wait until the page is ready'); + } $steps[] = new Given('I set the field "' . get_string('calculation', 'grades') . '" to "' . $calculation . '"'); $steps[] = new Given('I press "' . $savechanges . '"'); diff --git a/grade/tests/behat/grade_minmax.feature b/grade/tests/behat/grade_minmax.feature index 2102bfdcf2b..ad5f2325a87 100644 --- a/grade/tests/behat/grade_minmax.feature +++ b/grade/tests/behat/grade_minmax.feature @@ -4,7 +4,6 @@ Feature: We can choose what min or max grade to use when aggregating grades. As an teacher I can update modify a course setting - @javascript Scenario: Changing the min or max grade to use updates the grades accordingly Given the following "courses" exist: | fullname | shortname | category | groupmode |