diff --git a/src/Driver/CoreDriver.php b/src/Driver/CoreDriver.php index 9b4c04e43..37fde7e5b 100644 --- a/src/Driver/CoreDriver.php +++ b/src/Driver/CoreDriver.php @@ -177,6 +177,14 @@ public function setValue($xpath, $value) throw new UnsupportedDriverActionException('Setting the field value is not supported by %s', $this); } + /** + * {@inheritdoc} + */ + public function sendKeys($xpath, $value) + { + throw new UnsupportedDriverActionException('Setting the auto-complete field value is not supported by %s', $this); + } + /** * {@inheritdoc} */ diff --git a/src/Driver/DriverInterface.php b/src/Driver/DriverInterface.php index 0880960c7..cd7c08f79 100644 --- a/src/Driver/DriverInterface.php +++ b/src/Driver/DriverInterface.php @@ -365,6 +365,19 @@ public function getValue($xpath); */ public function setValue($xpath, $value); + /** + * Sends keys to an element by it's XPath query. + * + * @param string $xpath + * @param string|bool|array $value + * + * @throws UnsupportedDriverActionException When operation not supported by the driver + * @throws DriverException When the operation cannot be done + * + * @see \Behat\Mink\Element\NodeElement::setAutocompleteValue + */ + public function sendKeys($xpath, $value); + /** * Checks checkbox by it's XPath query. * diff --git a/src/Element/NodeElement.php b/src/Element/NodeElement.php index bbb857332..4fb52a50e 100644 --- a/src/Element/NodeElement.php +++ b/src/Element/NodeElement.php @@ -105,6 +105,18 @@ public function setValue($value) $this->getDriver()->setValue($this->getXpath(), $value); } + /** + * Sends keys to an input element + * + * Calling this method on other elements than form fields is not allowed. + * + * @param string|bool|array $value + */ + public function sendKeys($value) + { + $this->getDriver()->sendKeys($this->getXpath(), $value); + } + /** * Checks whether element has attribute with specified name. *