21

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>
Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820

8 Answers8

18

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. :)

Antoine Subit
  • 9,803
  • 4
  • 36
  • 52
user2866893
  • 220
  • 2
  • 3
15

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/

user2718671
  • 2,866
  • 9
  • 49
  • 86
wentbackward
  • 546
  • 3
  • 11
10

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.

Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
Emmanuel Angelo.R
  • 1,545
  • 2
  • 16
  • 24
8

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}
Sasha Brocato
  • 673
  • 10
  • 14
3

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

vcRobe
  • 1,671
  • 3
  • 17
  • 35
1

Clear text field using Ctrl+A and Del (for Selenium IDE):

<tr>
<td>keyDown</td>
<td>id=your text field id</td>
<td>\17</td>

<tr>
<td>keyPress</td>
<td>id=your text field id</td>
<td>\65</td>

<tr>
<td>keyUp</td>
<td>id=your text field id</td>
<td>\17</td>

<tr>
<td>keyPress</td>
<td>id=your text field id</td>
<td>\127</td>

Nani
  • 11
  • 1
0

The Best Answer to the qs how to Record the Enter Key Through Selenium IDE

<tr>
<td>keyDown</td>
<td>id=txtFilterContentUnit</td>
<td>\13 </td>
</tr>

Its Working i tried that on Selenium IDE here. replace txtFilterContentUnit with your text box name.

hope u can do it -Abhijeet

Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
Abhijeet
  • 69
  • 7
0

You can use code 13 for enter key, code 9 for tab key, code 40 for down key, 8 for backspace key

animuson
  • 53,861
  • 28
  • 137
  • 147
Rohit Ware
  • 1,982
  • 1
  • 13
  • 29