Selenium-IDE: How to simulate non-printable keys (ENTER, ESC, Backspace)?

76,306

Solution 1

For example to submit a form by pressing enter, the only one I can figure out is:

Command: keyPressAndWait
Target:  id=q              [depends on your form of course]
Value:   \\13              [for enter - any ascii value can go here]

So it looks like this:

<tr>
<td>keyPressAndWait</td>
<td>id=q</td>
<td>\13</td>
</tr>

Hope it helps Paul

Update:

keyPressAndWait is deprecated

Now you can use:

Command: sendKeys,

Target: id=<your id>,

Value: <your letter in utf8 and not ascii anymore>

For non-printable keys you can have a look at this page: http://www.testingdiaries.com/selenium-ide-keypress-events/

Solution 2

None of the solutions above helped me, however, the special keys described here this did the trick:

http://blog.reallysimplethoughts.com/2013/09/25/using-special-keys-in-selenium-ide-part-1/

sendKeys | id=search | ${KEY_ENTER}

Special keys - like normal keys, only a bit special. :)

Solution 3

you can use ${KEY_ENTER} and for other keys as the same as ${KEY_F8},${KEY_ESC}.. etc

Here is a blog post with more details.

Solution 4

For the newer versions of Firefox (22 & 23) the typeKeys command won't work in the Selenium IDE. It's deprecated. You have to use sendKeys.

command = sendKeys 
target = css=.someclass 
value = ${KEY_ENTER}

If you want to combine text with special keys you can do something like:

command = sendKeys 
target = css=.someclass 
value = demo${KEY_ENTER}

Solution 5

These methods doesn't work with the TAB key.

To simulate the TAB key pressed we need to use the command fireEvent like this

enter image description here

Share:
76,306
Aaron Digulla
Author by

Aaron Digulla

I'm a software developer living in Switzerland. You can reach me at digulla at hepe dot com.

Updated on January 04, 2020

Comments

  • Aaron Digulla
    Aaron Digulla over 4 years

    What is the exact HTML code to simulate ENTER, ESC, BACKSPACE and DOWN in Selenium IDE 1.3.0?

    typeKeys didn't work nor did this:

    <tr>
        <td>keyDown</td>
        <td>id=zc_0_4_3-real</td>
        <td>10</td>
    </tr>
    <tr>
        <td>keyUp</td>
        <td>id=zc_0_4_3-real</td>
        <td>10</td>
    </tr>
    <tr>
        <td>keyPress</td>
        <td>id=zc_0_4_3-real</td>
        <td>10</td>
    </tr>
    
  • SystemicPlural
    SystemicPlural over 12 years
    For anyone else encountering the \\13 problem. Ensure you are using the correct command, eg keyPress, and not typeKeys.
  • Michael
    Michael almost 11 years
    This is not recording anything, this is manual typing you have to do yourself, right?
  • Engineer2021
    Engineer2021 almost 11 years
    Right, don't use sendKeys. Use keyPress
  • SSP
    SSP over 10 years
    add content in ur answer
  • Aaron Digulla
    Aaron Digulla over 10 years
    Is that documented somewhere?
  • Emmanuel Angelo.R
    Emmanuel Angelo.R over 10 years
    dont know, but i have used in my testing today. if needed use in your testing
  • Emmanuel Angelo.R
    Emmanuel Angelo.R over 10 years
    @AaronDigulla thanks that was the perfect dot com where i searched for.
  • charles ross
    charles ross almost 8 years
    It's documented Here! And thank you for that Emmanuel Angelo R.