. /** * Auto complete form field class. * * @package core_form * @category test * @copyright 2015 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__ . '/behat_form_text.php'); /** * Auto complete form field. * * @package core_form * @category test * @copyright 2015 Damyon Wiese * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class behat_form_autocomplete extends behat_form_text { /** * Sets the value to a field. * * @param string $value * @return void */ public function set_value($value) { if (!$this->running_javascript()) { throw new coding_exception('Setting the valid of an autocomplete field requires javascript.'); } $this->field->setValue($value); $id = $this->field->getAttribute('id'); $js = ' require(["jquery"], function($) { $(document.getElementById("'.$id.'")).trigger("behat:set-value"); }); '; $this->session->executeScript($js); } }