The current Press Key keyword has a severe limitation that pressing special keys like tab requires using escaped ASCII codes like \09 (double escaping needed because \ itself is an escape character in Robot's data) and not all special keys (e.g. arrows) are supported.
Issue #275 proposed adding support for WebDriver's special keys like ARROR_UP to Press Key and it was implemented by PR #474 in version 1.7.3. Unfortunately this change broke undocumented (and tested) feature in Press Key to allow pressing multiple keys (#489). Such a backwards incompatible change was not considered a good idea, especially in a minor release, and changes were reverted in 1.7.4.
The general consensus in the comments of the aforementioned issues and pull requests tracker and on the Slack channel seems to be the following:
-
Normal keys should be supported directly. Examples: f (one key), FOO (three keys).
-
Escaped ASCII codes (e.g. \09) supported by Press Key is not supported. They are hard to read, hard to use (double escaping), add complexity to code, and simply have no benefits over named keys.
-
WebDriver's named special keys (e.g. CONTROL, END) should be supported. They should, however, be supported only when used alone or separated with + that is used as a modifier separator. This avoids named keys accidentally matching something like BEND or AALTO and also simplifies implementation because there is no need to scan the whole string for named keys.
-
Common aliases should be added to named keys when appropriate. For example, CTRL should be an alias for CONTROL and ESC should be alias for ESCAPE.
-
It should be possible to pass multiple keys also as separate arguments. This makes it possible to use | E | N | D | (| used as argument separator) if you want to press those three keys and not single key
-
If locator is not defined, sends the keys to the currently active browser.
-
The separator between modifiers and keys should be + with no spaces around. Other separators are not supported.
| `Press Keys` | text_field | AAAAA | | # Sends string "AAAAA" to element identified by text_field |
| `Press Keys` | None | BBBBB | | # Sends string "BBBBB" to currently active browser |
| `Press Keys` | text_field | CTRL+c | | # Pressing CTRL key down, sends string "c" and then releases CTRL key |
| `Press Keys` | text_field | E+N+D | | # Sends string "END" to element identified by text_field |
| `Press Keys` | text_field | XXX | YY | # Sends strings "XXX" and "YY" to element identified by text_field |
| `Press Keys` | button | RETURN | | # Press enter key to element identified by button |
This issue replaces issue #498
The current Press Key keyword has a severe limitation that pressing special keys like tab requires using escaped ASCII codes like \09 (double escaping needed because \ itself is an escape character in Robot's data) and not all special keys (e.g. arrows) are supported.
Issue #275 proposed adding support for WebDriver's special keys like ARROR_UP to Press Key and it was implemented by PR #474 in version 1.7.3. Unfortunately this change broke undocumented (and tested) feature in
Press Keyto allow pressing multiple keys (#489). Such a backwards incompatible change was not considered a good idea, especially in a minor release, and changes were reverted in 1.7.4.The general consensus in the comments of the aforementioned issues and pull requests tracker and on the Slack channel seems to be the following:
Normal keys should be supported directly. Examples: f (one key), FOO (three keys).
Escaped ASCII codes (e.g. \09) supported by Press Key is not supported. They are hard to read, hard to use (double escaping), add complexity to code, and simply have no benefits over named keys.
WebDriver's named special keys (e.g.
CONTROL,END) should be supported. They should, however, be supported only when used alone or separated with+that is used as a modifier separator. This avoids named keys accidentally matching something like BEND or AALTO and also simplifies implementation because there is no need to scan the whole string for named keys.Common aliases should be added to named keys when appropriate. For example,
CTRLshould be an alias forCONTROLandESCshould be alias forESCAPE.It should be possible to pass multiple keys also as separate arguments. This makes it possible to use
| E | N | D |(| used as argument separator) if you want to press those three keys and not single keyIf locator is not defined, sends the keys to the currently active browser.
The separator between modifiers and keys should be
+with no spaces around. Other separators are not supported.This issue replaces issue #498