Blog | Eficode

JavaFX app testing made simple with Python based Robot Framework

Written by Sami Pesonen | Mar 28, 2018 11:25:56 AM

There has been long time Robot Framework test library for Java Swing widget set but JavaFX has been missing. As we had the need we started checking toolsets for JavaFX at spring 2017 and found out TestFX which is versatile unit test framework for JavaFX.

We (me, Jukka Haavisto and Pasi Saikkonen) started implementing wrapper library based on TestFX and made initial tests with Jybot (using Jython) which is Java implementation of Robot Framework. We started to use this library with real customer application. As part of the project we had also other Python based test libraries in use for web testing and API testing and soon understood that Jython dependency is not that good idea as Python 2.7 support is dropping in 2020. Python based test stacks are moving to Python 3 direction and Jython does not support Python 3 yet. So we implemented remote library support for it which brings possibility to use Robot Framework as such (either with 2.7.x or 3.x Python). We think this is way to go for Robot libraries in general if something else than Python is used.

We are really excited and thankful for Eficode for this opportunity to Open Source this library and it is now released with Apache 2.0 license in Github. It is freely available for you to use. Just download Jar file from release area, start it with `java -jar JavaFXLibrary-<version>.jar` and you have JavaFXLibrary listening at 192.168.x.y port 8270.

After this below kind of test suite can be run with Python based Robot Framework:

In this example, in suite setup is started TestKeyboardRobot test application that is in Java classpath. In test itself it clicks a label with an id `keyCombinationLabel` and pushes keyboard key combination CTRL+SHIFT+G. Then it verifies that `keyCombinationLabel` label has value `Passed`. UI objects can be identified with id, styleClass and text. Also combination of previous and index (if several found) can be used. To identify UI objects you can use Scenicview application which is also free to download.

JavaFXLibrary repository in Github has acceptance tests (169 at time of this writing) for all provided keywords, feel free to try it as demo to see what it can do. We plan to arrange Robot Framework meetups in Tampere and Helsinki Finland where we plan to introduce this library face to face during this year. Stay tuned.

Do you have a need to get your acceptance tests to a next level? Do you have interface/UI/app with difficult to automate interface? Do you have need to automate multiple interfaces at same time? Contact us and we will help you!