Skip to content

Commit 4313f18

Browse files
author
davert
committed
added license docblock
1 parent 24e8f6c commit 4313f18

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

lib/WebDriverKeys.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class WebDriverKeys {
8484
const COMMAND = "\xEE\x80\xBD"; // ALIAS
8585
const ZENKAKU_HANKAKU = "\xEE\x80\xC0";
8686

87-
static function encode($keys)
87+
static function encode(array $keys)
8888
{
8989
$encoded = array();
9090
foreach ($keys as $key)

lib/__init__.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
require_once('WebDriverKeys.php');
2626
require_once('WebDriverNavigation.php');
2727
require_once('WebDriverMouse.php');
28+
require_once('WebDriverKeyboard.php');
2829
require_once('WebDriverOptions.php');
2930
require_once('WebDriverPoint.php');
3031
require_once('WebDriverSelect.php');

lib/remote/RemoteKeyboard.php

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
<?php
2+
// Copyright 2004-present Facebook. All Rights Reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
215

3-
16+
/**
17+
* Execute keyboard commands for RemoteWebDriver.
18+
*/
419
class RemoteKeyboard implements WebDriverKeyboard {
520

621
private $executor;
@@ -18,7 +33,7 @@ public function __construct($executor) {
1833
* @return $this
1934
*/
2035
public function sendKeys($keys) {
21-
$this->sendKeysToActiveElement(WebDriverKeys::encode($keys));
36+
$this->sendKeysToActiveElement(WebDriverKeys::encode(func_get_args()));
2237
return $this;
2338
}
2439

@@ -31,8 +46,7 @@ public function sendKeys($keys) {
3146
*/
3247
public function press($key)
3348
{
34-
$this->ensureModifier($key);
35-
$this->sendKeysToActiveElement(WebDriverKeys::encode(array($key)));
49+
$this->sendKeysToActiveElement($this->getModifierKey($key));
3650
return $this;
3751
}
3852

@@ -45,8 +59,7 @@ public function press($key)
4559
*/
4660
public function release($key)
4761
{
48-
$this->ensureModifier($key);
49-
$this->sendKeysToActiveElement(WebDriverKeys::encode(array($key)));
62+
$this->sendKeysToActiveElement($this->getModifierKey($key));
5063
return $this;
5164
}
5265

@@ -58,9 +71,10 @@ private function sendKeysToActiveElement($value)
5871
$this->executor->execute('sendKeysToActiveElement', $params);
5972
}
6073

61-
private function ensureModifier($key)
74+
private function getModifierKey($key)
6275
{
6376
if (!in_array($key, $this->modifiers))
6477
throw new InvalidArgumentException("$key is not a modifier key, expected one of ".implode(', ',$this->modifiers));
78+
return array(constant('WebDriverKeys::'.strtoupper($key)));
6579
}
6680
}

0 commit comments

Comments
 (0)