File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
javascript/node/selenium-webdriver/lib Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -1911,22 +1911,24 @@ class WebElement {
1911
1911
* punctionation keys will be synthesized according to a standard QWERTY en-us
1912
1912
* keyboard layout.
1913
1913
*
1914
- * @param {...(string|!promise.Promise<string>) } var_args The
1915
- * sequence of keys to type. All arguments will be joined into a single
1914
+ * @param {...(number|string|!IThenable<(number|string)>) } var_args The
1915
+ * sequence of keys to type. Number keys may be referenced numerically or
1916
+ * by string (1 or '1'). All arguments will be joined into a single
1916
1917
* sequence.
1917
1918
* @return {!promise.Promise<void> } A promise that will be resolved
1918
1919
* when all keys have been typed.
1919
1920
*/
1920
1921
sendKeys ( var_args ) {
1921
- // Coerce every argument to a string. This protects us from users that
1922
- // ignore the jsdoc and give us a number (which ends up causing problems on
1923
- // the server, which requires strings).
1924
1922
let keys = Promise . all ( Array . prototype . slice . call ( arguments , 0 ) ) .
1925
1923
then ( keys => {
1926
1924
let ret = [ ] ;
1927
1925
keys . forEach ( key => {
1928
- if ( typeof key !== 'string' ) {
1926
+ let type = typeof key ;
1927
+ if ( type === 'number' ) {
1929
1928
key = String ( key ) ;
1929
+ } else if ( type !== 'string' ) {
1930
+ throw TypeError (
1931
+ 'each key must be a number of string; got ' + type ) ;
1930
1932
}
1931
1933
1932
1934
// The W3C protocol requires keys to be specified as an array where
@@ -1935,6 +1937,7 @@ class WebElement {
1935
1937
} ) ;
1936
1938
return ret ;
1937
1939
} ) ;
1940
+
1938
1941
if ( ! this . driver_ . fileDetector_ ) {
1939
1942
return this . schedule_ (
1940
1943
new command . Command ( command . Name . SEND_KEYS_TO_ELEMENT ) .
You can’t perform that action at this time.
0 commit comments