Definite's Extractor

My findings on Life, Linux, Open Source, and so on.

Selenium key combination handling

I am working on the testing our new web-based translation management system, flies with selenium.

I used to stuck on emulating the key combination handling, such as Ctrl-Enter until recently. Here are steps to emulate a Ctrl-Enter.

controlKeyDown
keyDown theElement \13
keyPress theElement \13
keyUp theElement \13
controlKeyUp

The “theElement” is the web element that you want your hot keys to be press on. Yes, you need all keyDown, keyPress, and keyUp events.

Note that PageUp and PageDown might not be working. As their keycodes seems to collide with ! and ".

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: