Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# to automate Java application with Java Access Bridge

I have a Java application that I want to automate for testing. Unfortunately, the app window only registers as a SunAWTFrame, which means none of the controls are exposed to typical window analysis and automation tools.

My search has lead me to C# and utilising Java Access Bridge DLLS in a C# program to automate it.

Has anyone had any experience of this?

Oracle provides JavaAccessBridge (JAB) with some DLLS to help with this as I understand it after reading a few articles around the internet. There are some code examples but I'm really not groking it right now. By breaking it down, I think this is what needs to be achieved:

  1. Import / load / parse the JAB dlls
  2. Map functions in the JAB dll to methods / calls within my program
  3. Have the Java application to automate run (with JAB enabled) and get handle of it to my program
  4. Utilise the JAB functions to control the Java application

I don't know C# as well as I know Java, but that's not going to stop me.

If anyone can provide help, guidance, pointers or anything to get me started, that'd be truly awesome.

like image 496
Jegan Kumar Avatar asked Sep 05 '26 17:09

Jegan Kumar


1 Answers

As of 2019 we have a great tool AccessBridgeExplorer created and open-sourced by google. It's a really good staring point that contains a WindowsAccessBridgeInterop project which encapsulates almost every JAB API into a class oriented, .NET friendly assembly.

One notable thing, AccessBridge.Initialize() must be called in WPF/WinForm UI thread or in your own messaging pump thread, otherwise some methods like AccessBridge.EnumJvms() will always return false/empty.

like image 111
Stackia Avatar answered Sep 07 '26 07:09

Stackia



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!