. /** * Navigation steps definitions. * * @package core * @category test * @copyright 2012 David Monllaó * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ // NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php. require_once(__DIR__ . '/../../behat/behat_base.php'); /** * Steps definitions to navigate through the navigation tree nodes. * * @package core * @category test * @copyright 2012 David Monllaó * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class behat_navigation extends behat_base { /** * Expands the selected node of the navigation tree that matches the text. * @Given /^I expand "(?P(?:[^"]|\\")*)" node$/ * * @throws ElementNotFoundException Thrown by behat_base::find * @param string $nodetext */ public function i_expand_node($nodetext) { // This step is useless with Javascript disabled as Moodle auto expands // all of tree's nodes; adding this because of scenarios that shares the // same steps with and without Javascript enabled. if (!$this->running_javascript()) { return false; } $xpath = "//ul[contains(concat(' ', normalize-space(@class), ' '), ' block_tree ')] /child::li /child::p[contains(concat(' ', normalize-space(@class), ' '), ' branch')] /child::span[contains(concat(' ', normalize-space(.), ' '), '" . $nodetext . "')] | //ul[contains(concat(' ', normalize-space(@class), ' '), ' block_tree ')] /descendant::li[not(contains(concat(' ', normalize-space(@class), ' '), ' collapsed'))] /descendant::li /child::p[contains(concat(' ', normalize-space(@class), ' '), ' branch')] /child::span[contains(concat(' ', normalize-space(.), ' '), '" . $nodetext . "')] "; $node = $this->find('xpath', $xpath); $node->click(); } }