diff --git a/composer.json b/composer.json index 1e4ba6031..dbac39538 100644 --- a/composer.json +++ b/composer.json @@ -45,7 +45,7 @@ "extra": { "branch-alias": { - "dev-master": "1.7.x-dev" + "dev-master": "1.8.x-dev" } } } diff --git a/src/Driver/CoreDriver.php b/src/Driver/CoreDriver.php index 9b4c04e43..a4939e62a 100644 --- a/src/Driver/CoreDriver.php +++ b/src/Driver/CoreDriver.php @@ -417,6 +417,14 @@ public function keyUp($xpath, $char, $modifier = null) throw new UnsupportedDriverActionException('Keyboard manipulations are not supported by %s', $this); } + /** + * {@inheritdoc} + */ + public function pressKey($xpath, $char, $modifier = null) + { + throw new UnsupportedDriverActionException('Keyboard manipulations are not supported by %s', $this); + } + /** * {@inheritdoc} */ diff --git a/src/Driver/DriverInterface.php b/src/Driver/DriverInterface.php index 0880960c7..219e2ee0b 100644 --- a/src/Driver/DriverInterface.php +++ b/src/Driver/DriverInterface.php @@ -525,6 +525,8 @@ public function blur($xpath); * * @throws UnsupportedDriverActionException When operation not supported by the driver * @throws DriverException When the operation cannot be done + * + * @deprecated since version 1.8.0. Use "pressKey" instead, which is WebDriver (W3C) compliant. */ public function keyPress($xpath, $char, $modifier = null); @@ -537,6 +539,8 @@ public function keyPress($xpath, $char, $modifier = null); * * @throws UnsupportedDriverActionException When operation not supported by the driver * @throws DriverException When the operation cannot be done + * + * @deprecated since version 1.8.0. Use "pressKey" instead, which is WebDriver (W3C) compliant. */ public function keyDown($xpath, $char, $modifier = null); @@ -549,9 +553,23 @@ public function keyDown($xpath, $char, $modifier = null); * * @throws UnsupportedDriverActionException When operation not supported by the driver * @throws DriverException When the operation cannot be done + * + * @deprecated since version 1.8.0. Use "pressKey" instead, which is WebDriver (W3C) compliant. */ public function keyUp($xpath, $char, $modifier = null); + /** + * Send a sequence of key strokes to the active element + * + * @param string $xpath + * @param string|int $char could be either char ('b') or char-code (98) + * @param string $modifier keyboard modifier (could be 'ctrl', 'alt', 'shift' or 'meta') + * + * @throws UnsupportedDriverActionException When operation not supported by the driver + * @throws DriverException When the operation cannot be done + */ + public function pressKey($xpath, $char, $modifier = null); + /** * Drag one element onto another. * diff --git a/src/Element/NodeElement.php b/src/Element/NodeElement.php index bbb857332..41ea817c2 100644 --- a/src/Element/NodeElement.php +++ b/src/Element/NodeElement.php @@ -310,9 +310,12 @@ public function blur() * * @param string|int $char could be either char ('b') or char-code (98) * @param string $modifier keyboard modifier (could be 'ctrl', 'alt', 'shift' or 'meta') + * + * @deprecated since version 1.8.0. Use "pressKey" instead, which is WebDriver (W3C) compliant. */ public function keyPress($char, $modifier = null) { + @trigger_error('Method "keyPress" is deprecated since version 1.8.0. Use "pressKey" instead, which is WebDriver (W3C) compliant.', E_USER_DEPRECATED); $this->getDriver()->keyPress($this->getXpath(), $char, $modifier); } @@ -321,9 +324,12 @@ public function keyPress($char, $modifier = null) * * @param string|int $char could be either char ('b') or char-code (98) * @param string $modifier keyboard modifier (could be 'ctrl', 'alt', 'shift' or 'meta') + * + * @deprecated Deprecating in favor of `pressKey` which is WebDriver (W3C) compliant */ public function keyDown($char, $modifier = null) { + @trigger_error('Method "keyDown" is deprecated since version 1.8.0. Use "pressKey" instead, which is WebDriver (W3C) compliant.', E_USER_DEPRECATED); $this->getDriver()->keyDown($this->getXpath(), $char, $modifier); } @@ -332,12 +338,26 @@ public function keyDown($char, $modifier = null) * * @param string|int $char could be either char ('b') or char-code (98) * @param string $modifier keyboard modifier (could be 'ctrl', 'alt', 'shift' or 'meta') + * + * @deprecated Deprecating in favor of `pressKey` which is WebDriver (W3C) compliant */ public function keyUp($char, $modifier = null) { + @trigger_error('Method "keyUp" is deprecated since version 1.8.0. Use "pressKey" instead, which is WebDriver (W3C) compliant.', E_USER_DEPRECATED); $this->getDriver()->keyUp($this->getXpath(), $char, $modifier); } + /** + * Send a sequence of key strokes to the active element + * + * @param string|int $char could be either char ('b') or char-code (98) + * @param string $modifier keyboard modifier (could be 'ctrl', 'alt', 'shift' or 'meta') + */ + public function pressKey($char, $modifier = null) + { + $this->getDriver()->pressKey($this->getXpath(), $char, $modifier); + } + /** * Submits the form. * diff --git a/tests/Element/NodeElementTest.php b/tests/Element/NodeElementTest.php index 5ee860d8a..fa92bc0b7 100644 --- a/tests/Element/NodeElementTest.php +++ b/tests/Element/NodeElementTest.php @@ -502,6 +502,9 @@ public function testDragTo() $node->dragTo($target); } + /** + * @group legacy + */ public function testKeyPress() { $node = new NodeElement('elem', $this->session); @@ -514,6 +517,9 @@ public function testKeyPress() $node->keyPress('key'); } + /** + * @group legacy + */ public function testKeyDown() { $node = new NodeElement('elem', $this->session); @@ -526,6 +532,9 @@ public function testKeyDown() $node->keyDown('key'); } + /** + * @group legacy + */ public function testKeyUp() { $node = new NodeElement('elem', $this->session); @@ -538,6 +547,18 @@ public function testKeyUp() $node->keyUp('key'); } + public function testPressKey() + { + $node = new NodeElement('elem', $this->session); + + $this->driver + ->expects($this->once()) + ->method('pressKey') + ->with('elem', 'key'); + + $node->pressKey('key'); + } + public function testSubmitForm() { $node = new NodeElement('some_xpath', $this->session);