Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

selenium keyPress

Tags:

selenium-rc

I'm wondering how to use selenium's keyPress function to key in a string, it's easy to key a single character as:

selenium.keyPress("id=textbox", "\\119") (which  is character 'w');

but how can i key in an string say, 'face'? the following code would work but ugly:

selenium.keyPress("id=textbox", "\\102") (which  is character 'f');
selenium.keyPress("id=textbox", "\\97") (which  is character 'a');
selenium.keyPress("id=textbox", "\\99") (which  is character 'c');
selenium.keyPress("id=textbox", "\\101") (which  is character 'e');

and this one wont' work:

selenium.keyPress("id=textbox", "\\102\\97\\99\\101")
like image 723
ohana Avatar asked Feb 17 '26 17:02

ohana


1 Answers

Try using "typeKeys(id=textbox,face)".

Or if you want to do it in fast you can use type and for last char you can use keyPress to initiate the the key press event.

like image 197
lAH2iV Avatar answered Feb 19 '26 21:02

lAH2iV



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!