From bf4c3ee0ffc71747e1462c3cbca22fbc56a5a203 Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Fri, 19 Jun 2015 11:56:52 +0800 Subject: [PATCH] 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;