2 // This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
18 * Files interactions with behat overrides.
20 * @copyright 2016 Damyon Wiese
21 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 // NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
26 require_once(__DIR__ . '/../../../../lib/behat/behat_files.php');
28 use Behat\Mink\Exception\ExpectationException as ExpectationException,
29 Behat\Mink\Element\NodeElement as NodeElement;
32 * Files-related actions overrides.
34 * @copyright 2016 Damyon Wiese
35 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37 class behat_theme_boost_behat_files extends behat_files {
39 protected function get_filepicker_node($filepickerelement) {
41 // More info about the problem (in case there is a problem).
42 $exception = new ExpectationException('"' . $filepickerelement . '" filepicker can not be found', $this->getSession());
44 // If no file picker label is mentioned take the first file picker from the page.
45 if (empty($filepickerelement)) {
46 $filepickercontainer = $this->find(
48 "//*[@data-fieldtype=\"filemanager\"]",
52 // Gets the ffilemanager node specified by the locator which contains the filepicker container.
53 $filepickerelement = behat_context_helper::escape($filepickerelement);
54 $filepickercontainer = $this->find(
56 "//input[./@id = //label[normalize-space(.)=$filepickerelement]/@for]" .
57 "//ancestor::*[@data-fieldtype = 'filemanager' or @data-fieldtype = 'filepicker']",
62 return $filepickercontainer;