Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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>
like image 999
Aaron Digulla Avatar asked Oct 26 '11 15:10

Aaron Digulla


People also ask

What is Type key in selenium?

TypeKeys Method. DefaultSelenium. TypeKeys Method. WebDriver. Simulates keystroke events on the specified element, as though you typed the value key-by-key.

How do I add text to Selenium IDE?

We can type in a textbox using Selenium webdriver. We shall use the sendKeys() method to type in the edit box. It is an in-built method in Selenium. Let us consider a text box where we shall enter some text.


2 Answers

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

like image 60
user2866893 Avatar answered Oct 12 '22 15:10

user2866893


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/

like image 22
wentbackward Avatar answered Oct 12 '22 14:10

wentbackward