ohana
ohana

Reputation: 43

selenium keyPress

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")

Upvotes: 3

Views: 8097

Answers (2)

James Hornitzky
James Hornitzky

Reputation: 174

Tried the type command? | type | //input[@name='searchTerms'] | test |

Upvotes: 0

lAH2iV
lAH2iV

Reputation: 1159

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.

Upvotes: 1

Related Questions