I need to automate java swing desktop application and want to run functional scenarios including click on buttons, opening of drop down lists etc using cucumber. Is there any junit package/class that could support this type of testing?
1 Answer
First of all I do not know why you ask for a "junit package" since the problematic part is usually the interaction with Java applications, not the flow control behind them. So you should be able to integrate all of the following with cucumber (which is basically just an overblown pattern matcher) or the unit testing library of your choice.
Beyond those sementics: Java is actually quite difficult to automate. I did a little bit of research into it a year ago (so there might be something new on that front) so here are a few pointers:
Sikuli is a Framework that allows you to interact with an application under test based on the actual UI elements. It uses computer vision and uses the actual OS interfaces for mouse and keyboard interactions which makes it pretty much platform agnostic.
Pro:
- Reliable interaction with the AUT
- Easily procurable "selectors" in form of screenshots
- Well document
Contra:
- Screenshots are quite cumbersome to version alongsite the tests
- Setting it up with multiple testing instances via docker containers is challenging since the Linux support is fickle
- Currently only suppports Java for language bindings
- No insight into the internals of the AUT since it just operates on the UI level.
Jubula Jubula is a Framework more or less specialised in the automation of Java applications. It comes as a eclipse plugin and a set of Java client libraries that allow you to interact with the AUT programatically. It's honestly quite confusing but, if you have for example an existing testing framework using selenium it's use of text based selectors might make it easier to implement. At the start of 2019 I used it on a proiject I consulted on for a customer and I was able to write a basic WebDriver protocol conform Application Server so in theory you can do pretty much everything you could reasonably want to do with it but it doesn't make it easy for you to do so.
Pro:
- Easy to version string based selectors
- Interacts directly through Javas interfaces allowing for fast selector lookups
- Limited set of methods to check internal state of the application
Contra:
- Selectors are unreadable base64 strings
- It's extremely complicated to set up
- The Java API needs some adjustment for automation engineers used to e.g. the WebDriver Protocol
- It misses some rather crucial features (for example a way to look up an elements type)
- Some elements just aren't recognized by the application explorer which might force you to use hacky work arounds like using keyboard arrow keys instead of clicking somewhere.
Those two are the ones I found feasible to work with, other than that I also evaluated the Linux desktop testing project as well as PyAutoGUI but both didn't work for my project so I just mention them in case you want to give them a try, both will, if they run with your project, probably be less of a headache than Jubulas "documentation" or sikulis environment dependencies.
-
Hi Daniel, thanks for helpful reply. Could I ask about Jubula from security point of view? If the application needs to be highly secured and has sensitive data, is ubula reliable? Commented Sep 26, 2020 at 18:06
-
Jubula runs completely on your local system without network dependencies so there should be no problem regarding data leaks. It's in the end just a Java framework, even though it comes with an (imo.) unnecessarily complex development ecosystem.– DanielCommented Oct 1, 2020 at 4:58
-
I have been trying to launch .msi jswing desktop with Jubula but getting error Java binary not found. I have java se8 both jre and jdk installed on my windows. Also, there seems to be very less documentation on jubula. Commented Oct 2, 2020 at 23:26