MDL-45192 behat: Replacing specific-selector steps by a generic one
Having a I click on we can use all our selectors rather than having multiple steps for the same purpose. This step allow us to manage JS native dialogues without having to fail a scenario. Credit for Mohamed Alsharaf.
This commit is contained in:
@@ -60,21 +60,6 @@ class behat_forms extends behat_base {
|
||||
$buttonnode->press();
|
||||
}
|
||||
|
||||
/**
|
||||
* Presses button with specified id|name|title|alt|value, and confirming the alert dialog.
|
||||
*
|
||||
* @When /^I press "(?P<button_string>(?:[^"]|\\")*)", confirming the dialog$/
|
||||
* @throws ElementNotFoundException Thrown by behat_base::find
|
||||
* @param string $button
|
||||
*/
|
||||
public function press_button_confirm_dialog($button) {
|
||||
|
||||
// Ensures the button is present.
|
||||
$buttonnode = $this->find_button($button);
|
||||
$buttonnode->press();
|
||||
$this->getSession()->getDriver()->getWebDriverSession()->accept_alert();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills a form with field/value data. More info in http://docs.moodle.org/dev/Acceptance_testing#Providing_values_to_steps.
|
||||
*
|
||||
|
||||
@@ -190,21 +190,6 @@ class behat_general extends behat_base {
|
||||
$linknode->click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clicks link with specified id|title|alt|text, and confirming the alert dialog.
|
||||
*
|
||||
* @When /^I follow "(?P<link_string>(?:[^"]|\\")*)", confirming the dialog$/
|
||||
* @throws ElementNotFoundException Thrown by behat_base::find
|
||||
* @param string $link
|
||||
*/
|
||||
public function click_link_confirm_dialog($link) {
|
||||
|
||||
$linknode = $this->find_link($link);
|
||||
$this->ensure_node_is_visible($linknode);
|
||||
$linknode->click();
|
||||
$this->accept_currently_displayed_alert_dialog();
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits X seconds. Required after an action that requires data from an AJAX request.
|
||||
*
|
||||
@@ -297,6 +282,18 @@ class behat_general extends behat_base {
|
||||
$node->click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clicks the specified element and confirms the expected dialogue.
|
||||
*
|
||||
* @When /^I click on "(?P<element_string>(?:[^"]|\\")*)" "(?P<selector_string>[^"]*)" confirming the dialogue$/
|
||||
* @throws ElementNotFoundException Thrown by behat_base::find
|
||||
* @param string $link
|
||||
*/
|
||||
public function i_click_on_confirming_the_dialogue($element, $selectortype) {
|
||||
$this->i_click_on($element, $selectortype);
|
||||
$this->accept_currently_displayed_alert_dialog();
|
||||
}
|
||||
|
||||
/**
|
||||
* Click on the element of the specified type which is located inside the second element.
|
||||
*
|
||||
|
||||
@@ -100,26 +100,26 @@ Feature: Prevent or allow assignment submission changes
|
||||
And I follow "Test assignment name"
|
||||
When I follow "View/grade all submissions"
|
||||
And I set the field "selectall" to "1"
|
||||
And I press "Go", confirming the dialog
|
||||
And I click on "Go" "button" confirming the dialogue
|
||||
Then I should see "Submission changes not allowed" in the "Student 1" "table_row"
|
||||
And I should see "Submission changes not allowed" in the "Student 2" "table_row"
|
||||
And I log out
|
||||
When I log in as "student2"
|
||||
And I log in as "student2"
|
||||
And I follow "Course 1"
|
||||
And I follow "Test assignment name"
|
||||
Then I should not see "Edit submission"
|
||||
And I should not see "Edit submission"
|
||||
And I log out
|
||||
When I log in as "teacher1"
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I follow "Test assignment name"
|
||||
And I follow "View/grade all submissions"
|
||||
And I set the field "selectall" to "1"
|
||||
And I set the field "id_operation" to "Unlock submissions"
|
||||
And I press "Go", confirming the dialog
|
||||
Then I should not see "Submission changes not allowed" in the "Student 1" "table_row"
|
||||
And I click on "Go" "button" confirming the dialogue
|
||||
And I should not see "Submission changes not allowed" in the "Student 1" "table_row"
|
||||
And I should not see "Submission changes not allowed" in the "Student 2" "table_row"
|
||||
And I log out
|
||||
When I log in as "student2"
|
||||
And I log in as "student2"
|
||||
And I follow "Course 1"
|
||||
And I follow "Test assignment name"
|
||||
And I press "Edit submission"
|
||||
|
||||
Reference in New Issue
Block a user