Simulating Keypress Events in Selenium IDE

Since version 2.3.0, Selenium IDE supports keyboard keypress events. We can simulate Selenium IDE keypress events using newly introduced sendKeys command. Keypress events can be utilized in WebDriver Playback as well. All in all, it’s a very useful addition in Selenium IDE. Therefore in this tutorial, we will discuss about different options available in Selenium IDE to handle keyboard keypress events.

Let’s see how to use sendKeys in Selenium IDE. sendKeys command takes locator and value parameters just like any other Selenium IDE commands. To define a keyboard key, you just have to prefix its value with ‘KEY_’ text and write it as variable(Eg. using ${ }). For example, below command hits Enter key on button called ‘login’.

You can combine text with keys. For example, ‘Testing Diaris${KEY_LEFT}e’. You can also perform keypress with modifier keys such as Alt, Ctrl, Shift, Command(in Mac) etc. The first occurance of a modifier key presses them and the second one releases it. All modifier keys are released at the end of the sendKeys command. It will not affect the subsequent sendKeys command. Below is an exhaustive list of supported keyboard commands in Selenium IDE.

Navigation Keys:

  • KEY_LEFT (Navigation Left)
  • KEY_UP (Navigation Up)
  • KEY_RIGHT (Navigation Right)
  • KEY_DOWN (Navigation Down)
  • KEY_PGUP / KEY_PAGE_UP (Page up)
  • KEY_PGDN / KEY_PAGE_DOWN (Page down)
  • KEY_END (End)
  • KEY_HOME (Home)

Function Keys:

  • KEY_F1 to KEY_12 (Function keys from F1 to F12)

Modifier Keys:

  • KEY_ALT (Alt)
  • KEY_META / KEY_COMMAND (Command)
  • KEY_SHIFT (Shift)

Num Pad Keys:

  • KEY_NUMPAD0 / KEY_N0 to KEY_NUMPAD9 / KEY_N9 (Number keys from 1 to 9)
  • KEY_SEPARATOR/ KEY_SEP (Separator)

Misc. Keys:

  • KEY_BKSP / KEY_BACKSPACE (Backspace)
  • KEY_DEL / KEY_DELETE (Delete)
  • KEY_ENTER (Enter)
  • KEY_EQUALS (Equals)
  • KEY_ESC / KEY_ESCAPE (Escape)
  • KEY_INS / KEY_INSERT (Insert)
  • KEY_PAUSE (Pause)
  • KEY_SEMICOLON (Semi-colon)
  • KEY_SPACE (Space)
  • KEY_TAB (Tab)

Tip: Do not create any other stored variable in your Selenium IDE script with KEY_ prefix.

We hope you would find the above post illustrating Selenium IDE keypress events useful. Let us know your views in comments.


  1. Eloh
  2. fred
    • Pubsted
  3. jerryxn
  4. Neil

Leave a Reply

Your email address will not be published.