Commit e7c71c44 authored by David Monllaó's avatar David Monllaó
Browse files

MDL-42627 behat: Moving the deprecated method to behat_deprecate and updating scenarios

parent c3a40dea
......@@ -54,7 +54,7 @@ class behat_cohort extends behat_base {
$userid = $DB->get_field('user', 'id', array('username' => $username));
$steps = array(
new Given('I click on "' . get_string('assign', 'cohort') . '" "link" in the "' . $this->escape($cohortidnumber) . '" table row'),
new Given('I click on "' . get_string('assign', 'cohort') . '" "link" in the "' . $this->escape($cohortidnumber) . '" "table_row"'),
new Given('I select "' . $userid . '" from "' . get_string('potusers', 'cohort') . '"'),
new Given('I press "' . get_string('add') . '"'),
new Given('I press "' . get_string('backtocohorts', 'cohort') . '"')
......
......@@ -32,11 +32,11 @@ Feature: Upload users to a cohort
And I press "Upload users"
And I press "Continue"
And I follow "Cohorts"
And I click on "Assign" "link" in the "Cohort 1" table row
And I click on "Assign" "link" in the "Cohort 1" "table_row"
Then the "Current users" select box should contain "Tom Jones (tomjones@example.com)"
And the "Current users" select box should contain "Bob Jones (bobjones@example.com)"
And I press "Back to cohorts"
And I click on "Assign" "link" in the "Cohort 2" table row
And I click on "Assign" "link" in the "Cohort 2" "table_row"
And the "Current users" select box should contain "Mary Smith (marysmith@example.com)"
And the "Current users" select box should contain "Alice Smith (alicesmith@example.com)"
And I am on homepage
......
......@@ -60,7 +60,7 @@ Feature: Uniqueness of Group ID number
And I fill the moodle form with:
| Grouping ID number | GG2 |
And I press "Save changes"
And I click on "Edit" "link" in the "Grouping 1" table row
And I click on "Edit" "link" in the "Grouping 1" "table_row"
And I fill the moodle form with:
| Grouping ID number | GG2 |
And I press "Save changes"
......
......@@ -27,6 +27,8 @@
require_once(__DIR__ . '/../../../lib/behat/behat_base.php');
use Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException;
/**
* Deprecated behat step definitions.
*
......@@ -37,6 +39,37 @@ require_once(__DIR__ . '/../../../lib/behat/behat_base.php');
*/
class behat_deprecated extends behat_base {
/**
* Click on the specified element inside a table row containing the specified text.
*
* @deprecated since Moodle 2.7 MDL-42627
* @todo MDL-42862 This will be deleted in Moodle 2.9
* @see behat_general::i_click_on_in_the()
*
* @Given /^I click on "(?P<element_string>(?:[^"]|\\")*)" "(?P<selector_string>(?:[^"]|\\")*)" in the "(?P<row_text_string>(?:[^"]|\\")*)" table row$/
* @throws ElementNotFoundException
* @param string $element Element we look for
* @param string $selectortype The type of what we look for
* @param string $tablerowtext The table row text
*/
public function i_click_on_in_the_table_row($element, $selectortype, $tablerowtext) {
// Throw an exception if deprecated methods are not allowed otherwise allow it's execution.
$alternative = 'I click on "' . $this->escape($element) . '" "' . $this->escape($selectortype) .
'" in the "' . $this->escape($tablerowtext) . '" "table_row"';
$this->deprecated_message($alternative);
// The table row container.
$nocontainerexception = new ElementNotFoundException($this->getSession(), '"' . $tablerowtext . '" row text ');
$tablerowtext = $this->getSession()->getSelectorsHandler()->xpathLiteral($tablerowtext);
$rownode = $this->find('xpath', "//tr[contains(., $tablerowtext)]", $nocontainerexception);
// Looking for the element DOM node inside the specified row.
list($selector, $locator) = $this->transform_selector($selectortype, $element);
$elementnode = $this->find($selector, $locator, false, $rownode);
$elementnode->click();
}
/**
* Throws an exception if $CFG->behat_usedeprecated is not allowed.
*
......
......@@ -248,28 +248,6 @@ class behat_general extends behat_base {
$node->click();
}
/**
* Click on the specified element inside a table row containing the specified text.
*
* @Given /^I click on "(?P<element_string>(?:[^"]|\\")*)" "(?P<selector_string>(?:[^"]|\\")*)" in the "(?P<row_text_string>(?:[^"]|\\")*)" table row$/
* @throws ElementNotFoundException
* @param string $element Element we look for
* @param string $selectortype The type of what we look for
* @param string $tablerowtext The table row text
*/
public function i_click_on_in_the_table_row($element, $selectortype, $tablerowtext) {
// The table row container.
$nocontainerexception = new ElementNotFoundException($this->getSession(), '"' . $tablerowtext . '" row text ');
$tablerowtext = $this->getSession()->getSelectorsHandler()->xpathLiteral($tablerowtext);
$rownode = $this->find('xpath', "//tr[contains(., $tablerowtext)]", $nocontainerexception);
// Looking for the element DOM node inside the specified row.
list($selector, $locator) = $this->transform_selector($selectortype, $element);
$elementnode = $this->find($selector, $locator, false, $rownode);
$elementnode->click();
}
/**
* Drags and drops the specified element to the specified container. This step does not work in all the browsers, consider it experimental.
*
......
......@@ -15,7 +15,7 @@ Feature: Block users from contacting me
And I follow "Messages"
And I fill in "Search people and messages" with "User Two"
And I press "Search people and messages"
When I click on "Block contact" "link" in the "User Two" table row
When I click on "Block contact" "link" in the "User Two" "table_row"
Then the "Message navigation:" select box should contain "Blocked users (1)"
And I select "Blocked users (1)" from "Message navigation:"
And I should see "User Two"
......
......@@ -26,7 +26,7 @@ Feature: Message history displays correctly
And I click on "Messages" "link" in the "Navigation" "block"
And I fill in "Search people and messages" with "User Two"
And I press "Search people and messages"
And I click on "Message history" "link" in the "User Two" table row
And I click on "Message history" "link" in the "User Two" "table_row"
# The message history link shows all messages.
Then I should see "Message 1 from user1 to user2"
And I should see "Message 10 from user1 to user2"
......
......@@ -16,7 +16,7 @@ Feature: Manage contacts
And I click on "Messages" "link" in the "Navigation" "block"
And I fill in "Search people and messages" with "User Two"
And I press "Search people and messages"
When I click on "Add contact" "link" in the "User Two" table row
When I click on "Add contact" "link" in the "User Two" "table_row"
Then I should see "Message 1 from user1 to user2"
And I should see "Message 2 from user1 to user2"
And I should see "User Two" in the "#message_contacts" "css_element"
......
......@@ -16,7 +16,7 @@ Feature: Users can search their message history
And I fill in "Search people and messages" with "your biscuits"
And I press "Search people and messages"
Then I should see "User Two"
And I click on "context" "link" in the "User Two" table row
And I click on "context" "link" in the "User Two" "table_row"
And I should see "Give me your biscuits"
@javascript
......
......@@ -51,20 +51,20 @@ Feature: A history of each wiki page is available
And I follow "History"
# Checking that there are 3 history items (the first one is are th)
And "//*[@id='region-main']/descendant::table/descendant::tr[4]" "xpath_element" should exists
And I click on "1" "link" in the "Teacher 1" table row
And I click on "1" "link" in the "Teacher 1" "table_row"
And I should see "First edition"
And I should see "Teacher 1"
And I follow "History"
And I click on "2" "link" in the "Student 1" table row
And I click on "2" "link" in the "Student 1" "table_row"
And I should see "Second edition"
And I should see "Student 1"
And I follow "History"
And I click on "3" "link" in the "Student 2" table row
And I click on "3" "link" in the "Student 2" "table_row"
And I should see "Third edition"
And I should see "Student 2" in the "#region-main" "css_element"
And I follow "History"
And I click on "comparewith" "radio" in the "Student 1" table row
And I click on "compare" "radio" in the "Teacher 1" table row
And I click on "comparewith" "radio" in the "Student 1" "table_row"
And I click on "compare" "radio" in the "Teacher 1" "table_row"
And I press "Compare selected"
And I should see "Comparing version 1 with version 3"
And I follow "Next"
......
......@@ -24,7 +24,7 @@ Feature: A teacher can edit questions in the question bank
And I log in as "teacher1"
And I follow "Course 1"
And I follow "Question bank"
When I click on "Edit" "link" in the "Test question name" table row
When I click on "Edit" "link" in the "Test question name" "table_row"
And I fill the moodle form with:
| Question name | Edited question name |
| Question text | Write a lot about what you want |
......@@ -33,10 +33,10 @@ Feature: A teacher can edit questions in the question bank
And I should not see "Test question name"
And I should see "Admin User" in the ".categoryquestionscontainer tbody .creatorname" "css_element"
And I should see "Teacher 1" in the ".categoryquestionscontainer tbody .modifiername" "css_element"
And I click on "Edit" "link" in the "Edited question name" table row
And I click on "Edit" "link" in the "Edited question name" "table_row"
And the "Question name" field should match "Edited question name" value
And I press "Cancel"
And I click on "Preview" "link" in the "Edited question name" table row
And I click on "Preview" "link" in the "Edited question name" "table_row"
And I switch to "questionpreview" window
And I should see "Edited question name"
And I should see "Write a lot about what you want"
......
......@@ -24,7 +24,7 @@ Feature: A teacher can preview questions in the question bank
| fraction[0] | 100% |
| answer[1] | * |
| fraction[1] | None |
When I click on "Preview" "link" in the "Test question name" table row
When I click on "Preview" "link" in the "Test question name" "table_row"
And I switch to "questionpreview" window
And I fill the moodle form with:
| Whether correct | Shown |
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment