@@ -899,7 +899,26 @@ def simulate_event(self, locator: Union[WebElement, str], event: str):
899
899
900
900
@keyword
901
901
def press_key (self , locator : Union [WebElement , str ], key : str ):
902
- """*DEPRECATED in SeleniumLibrary 4.0.* use `Press Keys` instead."""
902
+ """Simulates user pressing key on element identified by ``locator``.
903
+
904
+ See the `Locating elements` section for details about the locator
905
+ syntax.
906
+
907
+ ``key`` is either a single character, a string, or a numerical ASCII
908
+ code of the key lead by '\\ '.
909
+
910
+ Examples:
911
+ | `Press Key` | text_field | q |
912
+ | `Press Key` | text_field | abcde |
913
+ | `Press Key` | login_button | \\ 13 | # ASCII code for enter key |
914
+
915
+ `Press Key` and `Press Keys` differ in the methods to simulate key
916
+ presses. `Press Key` uses the WebDriver `SEND_KEYS_TO_ELEMENT` command
917
+ using the selenium send_keys method. Although one is not recommended
918
+ over the other if `Press Key` does not work we recommend trying
919
+ `Press Keys`.
920
+ send_
921
+ """
903
922
if key .startswith ("\\ " ) and len (key ) > 1 :
904
923
key = self ._map_ascii_key_code_to_key (int (key [1 :]))
905
924
element = self .find_element (locator )
@@ -952,6 +971,13 @@ def press_keys(self, locator: Union[WebElement, None, str] = None, *keys: str):
952
971
| `Press Keys` | text_field | ALT | ARROW_DOWN | # Pressing "ALT" key and then pressing ARROW_DOWN. |
953
972
| `Press Keys` | text_field | CTRL+c | | # Pressing CTRL key down, sends string "c" and then releases CTRL key. |
954
973
| `Press Keys` | button | RETURN | | # Pressing "ENTER" key to element. |
974
+
975
+ `Press Key` and `Press Keys` differ in the methods to simulate key
976
+ presses. `Press Keys` uses the Selenium/WebDriver Actions.
977
+ `Press Keys` also has a more extensive syntax for describing keys,
978
+ key combinations, and key actions. Although one is not recommended
979
+ over the other if `Press Keys` does not work we recommend trying
980
+ `Press Key`.
955
981
"""
956
982
parsed_keys = self ._parse_keys (* keys )
957
983
if not is_noney (locator ):
0 commit comments