Skip to content

Commit 4548536

Browse files
committed
Merge pull request #494 from rtomac/press-key-hotfix
Reverted press key changes
2 parents eda046e + 75e70a0 commit 4548536

File tree

2 files changed

+14
-37
lines changed

2 files changed

+14
-37
lines changed

src/Selenium2Library/keywords/_element.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -485,26 +485,16 @@ def simulate(self, locator, event):
485485

486486
def press_key(self, locator, key):
487487
"""Simulates user pressing key on element identified by `locator`.
488-
489-
`key` is either a single character, a numerical ASCII code of the key lead by '\\\\',
490-
or a NAMED KEY as described in the [https://selenium.googlecode.com/git/docs/api/py/webdriver/selenium.webdriver.common.keys.html|Selenium docs].
491-
488+
`key` is either a single character, or a numerical ASCII code of the key
489+
lead by '\\\\'.
492490
Examples:
493-
| Press Key | text_field | q | # The letter 'q' |
494-
| Press Key | nav_console | ARROW_UP | # Named ARROW_UP key |
495-
| Press Key | login_button | \\\\13 | # ASCII code for Enter key |
496-
497-
It's recommended to use named keys over ascii escapes (.i.e ``ENTER`` over ``\\\\13``)
498-
499-
NAMED KEY value is new in Selenium2Library 1.7.3.
491+
| Press Key | text_field | q |
492+
| Press Key | login_button | \\\\13 | # ASCII code for enter key |
500493
"""
501-
if len(key) > 1:
502-
if key.startswith('\\'):
503-
key = self._map_ascii_key_code_to_key(int(key[1:]))
504-
else:
505-
key = self._map_named_key_code_to_special_key(key)
494+
if key.startswith('\\') and len(key) > 1:
495+
key = self._map_ascii_key_code_to_key(int(key[1:]))
506496
element = self._element_find(locator, True, True)
507-
# select it
497+
#select it
508498
element.send_keys(key)
509499

510500
# Public, links

test/acceptance/keywords/textfields.robot

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,13 @@ Input Password
2828
Verify Location Is "forms/submit.html"
2929

3030
Press Key
31-
[Documentation] Press Key
32-
[Setup] Go To Page "forms/login.html"
33-
#Cannot Be Executed in IE
34-
Input Text username_field James Bond
35-
Press Key username_field HOME
36-
Press Key username_field END
37-
Press Key username_field ARROW_LEFT
38-
Press Key username_field ARROW_LEFT
39-
Press Key username_field ARROW_LEFT
40-
Press Key username_field DELETE
41-
Press Key username_field ARROW_LEFT
42-
Press Key username_field ARROW_RIGHT
43-
Press Key username_field \\108 #This is the 'l' char
44-
Press Key username_field o
45-
${text} = Get Value username_field
46-
Should Be Equal ${text} James Blond
47-
Press Key password_field f
48-
Press Key password_field 9
49-
Press Key login_button ENTER
50-
Verify Location Is "forms/submit.html"
31+
[Setup] Go To Page "forms/login.html"
32+
Cannot Be Executed in IE
33+
Input Text username_field James Bond
34+
Press Key password_field f
35+
Press Key password_field \\9
36+
Press Key login_button \\10
37+
Verify Location Is "forms/submit.html"
5138

5239
Attempt Clear Element Text On Non-Editable Field
5340
[Documentation] Attempt Clear Element Text On Non-Editable Field

0 commit comments

Comments
 (0)