1
votes

Im trying to accelerate the use of a web application using selenium Webdriver by creating hotkeys for it. I want certain webdriver click events to be associated with keyboard keys. For example, pressing "s" on the keyboard will click on the submit button.

I understand how to do the clicking and locating elements with webdriver but don't know how to go about listening to the keys from Java while Firefox is open (from a webdriver get call). My application has no GUI and since it's opening a firefox window it will lose focus so KeyListener is not an option.

I have come accross the JNI library that I'm looking into. Any other suggestions how I may do this?

1
My honest opinion is to ask your developers to implement such key shortcuts directly to the page. Or else you will spend days developing something like java application with integrated web browser which is listening to key events... - Pavel Janicek
Hi Pavel, it is not my application but I need to use it daily and takes a lot of time to manually perform the repetitive tasks, that's why I'd like to create hotkeys for my personal use. I agree asking for the hotkeys to be added would be ideal if it were my app. When I say my application has no GUI, etc Im referring to the Java/WebDriver application Im developing that operates on the web application that is already there - garraty
Have come accross this library that may do the trick: kra.lc/blog/2011/07/java-global-system-hook - garraty
I used the java-global-system-hook for the keyboard from the link above and it's working. Has anyone used the .jar before and can verify it's not malicious code? It's derived from the JNI original library. - garraty

1 Answers

0
votes

In that case, it is almost always better idea to automate the whole process

Say, you need to daily update salary of the employees. It is better idea to invest your time to read XLS file (almost standard way how those data are delivered to the people destined to do the repetitive work) and read line by line and somehow enter it to the application.

I know I did not provide you the answer you were expecting, but try to think of automating the whole process. It might be little tricky, but doable - and at the end faster - than simple mapping of the keys