. /** * Files interactions with behat overrides. * * @copyright 2016 Damyon Wiese * @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__ . '/../../../../lib/behat/behat_files.php'); use Behat\Mink\Exception\ExpectationException as ExpectationException, Behat\Mink\Element\NodeElement as NodeElement; /** * Files-related actions overrides. * * @copyright 2016 Damyon Wiese * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class behat_theme_ilb_behat_files extends behat_files { protected function get_filepicker_node($filepickerelement) { // More info about the problem (in case there is a problem). $exception = new ExpectationException('"' . $filepickerelement . '" filepicker can not be found', $this->getSession()); // If no file picker label is mentioned take the first file picker from the page. if (empty($filepickerelement)) { $filepickercontainer = $this->find( 'xpath', "//*[@data-fieldtype=\"filemanager\"]", $exception ); } else { // Gets the ffilemanager node specified by the locator which contains the filepicker container. $filepickerelement = behat_context_helper::escape($filepickerelement); $filepickercontainer = $this->find( 'xpath', "//input[./@id = //label[normalize-space(.)=$filepickerelement]/@for]" . "//ancestor::*[@data-fieldtype = 'filemanager' or @data-fieldtype = 'filepicker']", $exception ); } return $filepickercontainer; } }