0

I want to partially automate some integration level tests via the use of the Robot class to send mouse/keyboard events to the the Java application I'm testing. I want the user to be able to click a button and have a number of keyboard events be automatically sent at once.

I spawn the application I want to test from inside my Robot test (using Runtime.exec) and then generate the appropriate events. Unfortunately when the user clicks a button the button has focus and receives the events instead of the events going to the child process as I would like. I would like a way to ensure that the Robot keyboard events are sent to the application I'm trying to test instead.

I've thought of fetching the child process PID and then using the FG command to bring the application I want to the foreground; but this is a Linux specific approach. I would prefer a method that works for Linux or Windows equally as well.

Jason Plank
  • 2,336
  • 5
  • 31
  • 40
drew
  • 577
  • 2
  • 8
  • 20
  • Could be a dupe of http://stackoverflow.com/questions/309023/howto-bring-a-java-window-to-the-front. – Femi Jun 30 '11 at 11:58
  • This is a different situation. I'm trying to bring a program in the foreground which is a different process (child of) the java application running the code. – drew Jun 30 '11 at 15:35
  • Oh. Yeah, I don't know that you will be able to find a platform-independent way of doing that. – Femi Jun 30 '11 at 16:17

1 Answers1

1

I don't know exactly what you are testing or how you are testing it but you should look into Sikuli - its a visual technology and there are methods that will let you either automatically click on a part of the screen you want to get focus, or use App.focus("application name"). I really recommend it. However using it will not let you use the computer to do other things while testing the program.

Hope that helps!

sjngm
  • 12,423
  • 14
  • 84
  • 114