mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 01:16:44 +02:00
MDL-49412 Behat: Add a 'I follow "x" in the user menu step'
Part of MDL-45774.
This commit is contained in:
parent
25c634df29
commit
7b05a0feb6
1 changed files with 31 additions and 2 deletions
|
@ -27,8 +27,10 @@
|
||||||
|
|
||||||
require_once(__DIR__ . '/../../behat/behat_base.php');
|
require_once(__DIR__ . '/../../behat/behat_base.php');
|
||||||
|
|
||||||
use Behat\Behat\Context\Step\Given as Given,
|
use Behat\Behat\Context\Step\Given as Given;
|
||||||
Behat\Mink\Exception\ExpectationException as ExpectationException;
|
use Behat\Mink\Exception\ExpectationException as ExpectationException;
|
||||||
|
use Behat\Mink\Exception\DriverException as DriverException;
|
||||||
|
use Behat\Behat\Context\Step\When as When;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Steps definitions to navigate through the navigation tree nodes.
|
* Steps definitions to navigate through the navigation tree nodes.
|
||||||
|
@ -135,6 +137,33 @@ class behat_navigation extends behat_base {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Click on an entry in the user menu.
|
||||||
|
* @Given /^I follow "(?P<nodetext_string>(?:[^"]|\\")*)" in the user menu$/
|
||||||
|
*
|
||||||
|
* @throws ExpectationException
|
||||||
|
* @param string $nodetext
|
||||||
|
* @return bool|void
|
||||||
|
*/
|
||||||
|
public function i_follow_in_the_user_menu($nodetext) {
|
||||||
|
|
||||||
|
// The user menu is broken without javascript.
|
||||||
|
if (!$this->running_javascript()) {
|
||||||
|
throw new DriverException('I follow in the user menu step is not available with Javascript disabled');
|
||||||
|
}
|
||||||
|
|
||||||
|
$steps = array();
|
||||||
|
|
||||||
|
$xpath = "//div[@class='usermenu']//a[contains(concat(' ', @class, ' '), ' toggle-display ')]";
|
||||||
|
$csspath = ".usermenu [data-rel='menu-content']";
|
||||||
|
|
||||||
|
$steps[] = new When('I click on "'.$xpath.'" "xpath_element"');
|
||||||
|
$steps[] = new When('I click on "'.$nodetext.'" "link" in the "'.$csspath.'" "css_element"');
|
||||||
|
|
||||||
|
return $steps;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expands the selected node of the navigation tree that matches the text.
|
* Expands the selected node of the navigation tree that matches the text.
|
||||||
* @Given /^I expand "(?P<nodetext_string>(?:[^"]|\\")*)" node$/
|
* @Given /^I expand "(?P<nodetext_string>(?:[^"]|\\")*)" node$/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue