Skip to content

Commit c6da675

Browse files
Add named keys to Press Key.
1 parent d6a42af commit c6da675

File tree

2 files changed

+44
-32
lines changed

2 files changed

+44
-32
lines changed

src/Selenium2Library/keywords/_element.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -483,10 +483,13 @@ def press_key(self, locator, key):
483483
lead by '\\\\'.
484484
485485
Examples:
486-
| Press Key | text_field | q |
487-
| Press Key | login_button | \\\\13 | # ASCII code for enter key |
486+
| Press Key | text_field | q | |
487+
| Press Key | login_button | \\\\13 | # ASCII code for enter key |
488+
| Press Key | nav_console | \\\\\\\\ARROW_UP | # selenium.webdriver.common.keys ARROW_UP KEY |
488489
"""
489-
if key.startswith('\\') and len(key) > 1:
490+
if key.startswith('\\\\') and len(key) > 1:
491+
key = getattr(Keys,key[2:])
492+
elif key.startswith('\\') and len(key) > 1:
490493
key = self._map_ascii_key_code_to_key(int(key[1:]))
491494
#if len(key) > 1:
492495
# raise ValueError("Key value '%s' is invalid.", key)
Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,49 @@
1-
*Setting*
2-
Variables variables.py
3-
Resource ../resource.robot
4-
Test Setup Go To Page "forms/prefilled_email_form.html"
5-
6-
7-
*Test Cases*
1+
*** Setting ***
2+
Test Setup Go To Page "forms/prefilled_email_form.html"
3+
Force Tags txtfields
4+
Variables variables.py
5+
Resource ../resource.robot
86

7+
*** Test Cases ***
98
Get Value From Text Field
10-
${text} = Get Value name
11-
Should Be Equal ${text} Prefilled Name
12-
Clear Element Text name
13-
${text} = Get Value name
14-
Should Be Equal ${text} ${EMPTY}
9+
${text} = Get Value name
10+
Should Be Equal ${text} Prefilled Name
11+
Clear Element Text name
12+
${text} = Get Value name
13+
Should Be Equal ${text} ${EMPTY}
1514

1615

1716
Input Unicode In Text Field
18-
Input Text name ${unic_text}
19-
${text} = Get Value name
20-
Should Be Equal ${text} ${unic_text}
17+
Input Text name ${unic_text}
18+
${text} = Get Value name
19+
Should Be Equal ${text} ${unic_text}
2120

2221
Input Password
23-
[Documentation] LOG 3 Typing password into text field 'password_field'
24-
[Setup] Go To Page "forms/login.html"
25-
Input Text username_field username
26-
Input Password password_field password
27-
Submit Form
28-
Verify Location Is "forms/submit.html"
22+
[Documentation] LOG 3 Typing password into text field 'password_field'
23+
[Setup] Go To Page "forms/login.html"
24+
Input Text username_field username
25+
Input Password password_field password
26+
Submit Form
27+
Verify Location Is "forms/submit.html"
2928

3029
Press Key
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"
30+
[Setup] Go To Page "forms/login.html"
31+
#Cannot Be Executed in IE
32+
Input Text username_field James Bond
33+
Press Key username_field \\\\HOME
34+
Press Key username_field \\\\END
35+
Press Key username_field \\\\ARROW_LEFT
36+
Press Key username_field \\\\ARROW_LEFT
37+
Press Key username_field \\\\ARROW_LEFT
38+
Press Key username_field \\\\ARROW_LEFT
39+
Press Key username_field \\\\ARROW_RIGHT
40+
Press Key username_field \\108 #This is the 'l' char
41+
${text} = Get Value username_field
42+
Should Be Equal ${text} James Blond
43+
Press Key password_field f
44+
Press Key password_field \\9
45+
Press Key login_button \\10
46+
Verify Location Is "forms/submit.html"
3847

3948
Attempt Clear Element Text On Non-Editable Field
40-
Run Keyword And Expect Error * Clear Element Text can_send_email
49+
Run Keyword And Expect Error * Clear Element Text can_send_email

0 commit comments

Comments
 (0)