Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Driver/CoreDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}
*/
Expand Down
18 changes: 18 additions & 0 deletions src/Driver/DriverInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 Deprecating in favor of `pressKey` which is WebDriver (W3C) compliant
*/
public function keyPress($xpath, $char, $modifier = null);

Expand All @@ -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 Deprecating in favor of `pressKey` which is WebDriver (W3C) compliant
*/
public function keyDown($xpath, $char, $modifier = null);

Expand All @@ -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 Deprecating in favor of `pressKey` 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.
*
Expand Down
17 changes: 17 additions & 0 deletions src/Element/NodeElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ 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 Deprecating in favor of `pressKey` which is WebDriver (W3C) compliant
*/
public function keyPress($char, $modifier = null)
{
Expand All @@ -321,6 +323,8 @@ 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)
{
Expand All @@ -332,12 +336,25 @@ 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)
{
$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.
*
Expand Down
12 changes: 12 additions & 0 deletions tests/Element/NodeElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,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);
Expand Down