@@ -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}
0 commit comments