Skip to content

Commit b69787d

Browse files
author
davert
committed
constants and strings can be passed as modifiers
1 parent 4313f18 commit b69787d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/remote/RemoteKeyboard.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,15 @@ class RemoteKeyboard implements WebDriverKeyboard {
2020

2121
private $executor;
2222

23-
protected $modifiers = array('control','shift','alt','command','meta');
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');
2432

2533
public function __construct($executor) {
2634
$this->executor = $executor;
@@ -73,8 +81,9 @@ private function sendKeysToActiveElement($value)
7381

7482
private function getModifierKey($key)
7583
{
84+
if (in_array($key, $this->modifierNames)) $key = constant('WebDriverKeys::'.strtoupper($key));
7685
if (!in_array($key, $this->modifiers))
77-
throw new InvalidArgumentException("$key is not a modifier key, expected one of ".implode(', ',$this->modifiers));
78-
return array(constant('WebDriverKeys::'.strtoupper($key)));
86+
throw new InvalidArgumentException("This is not a modifier key, expected ".implode(', ', $this->modifierNames));
87+
return array($key);
7988
}
8089
}

0 commit comments

Comments
 (0)