Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit 45c00d0

Browse files
author
davert
committed
java compatible interface, license
1 parent b69787d commit 45c00d0

File tree

3 files changed

+7
-24
lines changed

3 files changed

+7
-24
lines changed

lib/WebDriverKeyboard.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public function sendKeys($keys);
1212
* @param $key
1313
* @return $this
1414
*/
15-
public function press($key);
15+
public function pressKey($key);
1616

1717
/**
1818
* Release a modifier key
@@ -21,6 +21,6 @@ public function press($key);
2121
* @param $key
2222
* @return $this
2323
*/
24-
public function release($key);
24+
public function releaseKey($key);
2525

2626
}

lib/remote/RemoteKeyboard.php

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,6 @@ class RemoteKeyboard implements WebDriverKeyboard {
2020

2121
private $executor;
2222

23-
protected $modifiers = array(
24-
WebDriverKeys::CONTROL,
25-
WebDriverKeys::SHIFT,
26-
WebDriverKeys::ALT,
27-
WebDriverKeys::COMMAND,
28-
WebDriverKeys::META
29-
);
30-
31-
protected $modifierNames = array('control', 'shift', 'alt', 'command', 'meta');
3223

3324
public function __construct($executor) {
3425
$this->executor = $executor;
@@ -52,9 +43,9 @@ public function sendKeys($keys) {
5243
* @param $key
5344
* @return $this
5445
*/
55-
public function press($key)
46+
public function pressKey($key)
5647
{
57-
$this->sendKeysToActiveElement($this->getModifierKey($key));
48+
$this->sendKeysToActiveElement(array($key));
5849
return $this;
5950
}
6051

@@ -65,9 +56,9 @@ public function press($key)
6556
* @param $key
6657
* @return $this
6758
*/
68-
public function release($key)
59+
public function releaseKey($key)
6960
{
70-
$this->sendKeysToActiveElement($this->getModifierKey($key));
61+
$this->sendKeysToActiveElement(array($key));
7162
return $this;
7263
}
7364

@@ -76,14 +67,7 @@ private function sendKeysToActiveElement($value)
7667
$params = array(
7768
'value' => $value
7869
);
79-
$this->executor->execute('sendKeysToActiveElement', $params);
70+
$this->executor->execute('sendKeys', $params);
8071
}
8172

82-
private function getModifierKey($key)
83-
{
84-
if (in_array($key, $this->modifierNames)) $key = constant('WebDriverKeys::'.strtoupper($key));
85-
if (!in_array($key, $this->modifiers))
86-
throw new InvalidArgumentException("This is not a modifier key, expected ".implode(', ', $this->modifierNames));
87-
return array($key);
88-
}
8973
}

lib/remote/WebDriverCommandExecutor.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ class WebDriverCommandExecutor {
7171
'sendKeys' => array('method' => 'POST', 'url' => '/session/:sessionId/keys'),
7272
'sendKeysToAlert' => array('method' => 'POST', 'url' => '/session/:sessionId/alert_text'),
7373
'sendKeysToElement' => array('method' => 'POST', 'url' => '/session/:sessionId/element/:id/value'),
74-
'sendKeysToActiveElement' => array('method' => 'POST', 'url' => '/session/:sessionId/keys'),
7574
'setImplicitWaitTimeout' => array('method' => 'POST', 'url' => '/session/:sessionId/timeouts/implicit_wait'),
7675
'setPageLoadTimeout' => array('method' => 'POST', 'url' => '/session/:sessionId/timeouts'),
7776
'setScriptTimeout' => array('method' => 'POST', 'url' => '/session/:sessionId/timeouts/async_script'),

0 commit comments

Comments
 (0)