Differences Between: [Versions 310 and 311] [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403] [Versions 39 and 310]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Steps definitions to open and close action menus. 19 * 20 * @package core 21 * @category test 22 * @copyright 2016 Damyon Wiese 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 // NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php. 27 28 require_once (__DIR__ . '/../../behat/behat_base.php'); 29 30 use Behat\Mink\Exception\ExpectationException as ExpectationException; 31 use Behat\Mink\Exception\DriverException as DriverException; 32 33 /** 34 * Steps definitions to open and close action menus. 35 * 36 * @package core 37 * @category test 38 * @copyright 2016 Damyon Wiese 39 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 40 */ 41 class behat_action_menu extends behat_base { 42 43 /** 44 * Open the action menu in 45 * 46 * @Given /^I open the action menu in "(?P<element_string>(?:[^"]|\\")*)" "(?P<selector_string>[^"]*)"$/ 47 * @param string $element 48 * @param string $selector 49 * @return void 50 */ 51 public function i_open_the_action_menu_in($element, $selectortype) { 52 // Gets the node based on the requested selector type and locator. 53 $node = $this->get_node_in_container("css_element", "[role=button][aria-haspopup=true]", $selectortype, $element); 54 55 // Check if it is not already opened. 56 if ($node->getAttribute('aria-expanded') === 'true') { 57 return; 58 } 59 60 $this->ensure_node_is_visible($node); 61 $node->click(); 62 } 63 64 /** 65 * When an action menu is open, follow one of the items in it. 66 * 67 * @Given /^I choose "(?P<link_string>(?:[^"]|\\")*)" in the open action menu$/ 68 * @param string $linkstring 69 * @return void 70 */ 71 public function i_choose_in_the_open_action_menu($menuitemstring) { 72 if (!$this->running_javascript()) { 73 throw new DriverException('Action menu steps are not available with Javascript disabled'); 74 } 75 // Gets the node based on the requested selector type and locator. 76 $menuselector = ".moodle-actionmenu .dropdown.show .dropdown-menu"; 77 $node = $this->get_node_in_container("link", $menuitemstring, "css_element", $menuselector); 78 $this->ensure_node_is_visible($node); 79 $node->click(); 80 } 81 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body