r/javahelp • • Dec 24 '22

How do we automate a java application?

How can we get the DOM structure of a java application and automate it? Can we use JAAPI ?

0 Upvotes

13 comments sorted by

View all comments

3

u/dionthorn this.isAPro=false; this.helping=true; Dec 24 '22

https://docs.oracle.com/javase/7/docs/api/java/awt/Robot.html

This class is used to generate native system input events
for the purposes of test automation, self-running demos,
and other applications where control of the mouse and keyboard is needed.
The primary purpose of Robot is to
facilitate automated testing of Java platform implementations.

2

u/[deleted] Dec 24 '22

Would there be any other similar api if we need to automate platform independent (os) as well as framework independent (swing, javafx) java applications.

3

u/dionthorn this.isAPro=false; this.helping=true; Dec 24 '22

Robot can be used on any java application doesn't matter if it is Swing, JavaFX or any other.

For OS level keyboard/mouse listeners and events you can use JNativeHook project:

https://github.com/kwhat/jnativehook

which provides native global control of mouse and keyboard.

2

u/[deleted] Dec 24 '22

I see now, would use this . Very greatful for your help.