I need to select an item from a list and then simulate hitting enter in selenium code. I heard about using:
selenium.keyPressNative("\13");
to simulate it, but it thought that \13 was the male symbol... Anyone know the actual number? Or am i doin so开发者_C百科mething silly?
From the selenium JavaDoc on keyPressNative()
@param keycode an integer keycode number corresponding to a java.awt.event.KeyEvent; note that Java keycodes are NOT the same thing as JavaScript keycodes!
13 is the JavaScript key code for the Enter key, it is not the java.awt.event.KeyEvent
key code.
You could either switch to keyPress()
or supply the correct key code, which I believe is KeyEvent.VK_ENTER
which is \n
.
精彩评论