TestFX based Robot Framework library for testing JavaFX Applications.
JavaFXLibrary works with both Jython (local and remote use) and Python (remote only) versions of Robot Framework. This means JavaFXLibrary can be used with Jython incompatible test libraries too by importing it as a remote library.
JavaFXLibrary is tested to work with Java 8 and Robot Framework 3.2.1 or later.
See keyword documentation.
For editors (IDEs) keyword documentation can be obtained from here.
- Download JavaFXLibrary jar file from releases or Maven Central.
- Import JavaFXLibrary in test settings:
*** Settings ***
Library JavaFXLibrary
- Add library jar to Jython module search path and run your tests:
jython -J-cp javafxlibrary-<version>.jar -m robot.run tests.robot
- Download JavaFXLibrary jar file from releases or Maven Central.
- Start JavaFXLibrary as a remote library:
java -jar javafxlibrary-<version>.jar
- Remote library starts in port 8270 by default.
- Port number can also be defined in the start command:
java -jar javafxlibrary-<version>.jar 1234
- Import JavaFXLibrary in test settings:
*** Settings ***
Library Remote http://127.0.0.1:8270 WITH NAME JavaFXLibrary
- Run your tests:
robot tests.robot
MacOS Mojave introduced changes to security settings and disabled some of the features JavaFXLibrary uses by default. To use JavaFXLibrary on macOS Mojave you must enable the accessibility features for terminal in system preferences:
- Navigate to
Apple menu > System Preferences > Security & Privacy > Privacy > Accessibility
- Click the lock and enter your password to change these settings
- If terminal has requested accessibility features before it should show in the list
- If not, add it by clicking ➕ and selecting
Applications > Utilities > Terminal
- Enable accessibility features by checking the box: ✅ Terminal
Scenic View is a tool that allows you to inspect the JavaFX application scenegraph. This can be useful especially when you do not have access to the source code.
See keyword documentation for detailed information about handling UI elements with the library.
Library's acceptance test suite can be used as a JavaFXLibrary demo. Running the test suite requires Maven installation.
- Clone the repository:
git clone https://github.com/eficode/JavaFXLibrary.git
- Run acceptance tests (in repository root):
mvn verify
- Docker CE: https://docs.docker.com/install/
- Docker-compose: https://docs.docker.com/compose/install/
- Port 80 is free in your machine
- Build & start the Dockerized environment:
docker-compose up -d robot-framework javafxcompile
- Open browser to <docker_daemon_ip>
- Open xterm from Start menu > System tools > xterm
- Execute tests:
test.sh
Executing test.sh runs the acceptance suite twice: first using JavaFXLibrary as a local Robot Framework library on Jython, and after that using the library in remote mode executing the same tests on python version of Robot Framework.
If you want the suite to run only once, you can define which type of library to use by including local or remote as an argument. For example command test.sh remote
will execute the suite only in remote mode.
Library supports headless operation utilizing Monocle. The support for this is still at experimental level.
- Scrolling doesn't work same way as with screen
- "Tick" (amount of scrolling) is much smaller in headless than normally
- Vertical (left/right) scrolling is not working
- Separate app windows' can't be closed (unless app offers that functionality itself)
- Swing applications can't be tested in headless mode.
Headless mode can be enabled by setting first library initialization to "True".
Locally:
*** Settings ***
Library JavaFXLibrary ${True}
Remote:
*** Settings ***
Library Remote http://127.0.0.1:8270 ${True} WITH NAME JavaFXLibrary
Library can be used as java agent. Launch application with -javaagent:/path/to/javafxlibrary-<version>.jar
. Default port is 8270 and can be changed with adding =<port>
to java agent command. Only remote library is supported. Using launch keyword is still required but instead of starting new application keyword initializes Stage for library.