Java GUI Plugins/en
Inhaltsverzeichnis
Supported Java technologies[Bearbeiten]
expecco supports the automation of Java applications implemented with Java Swing, Java SWT or JavaFX. Also supported are applications that combine several of these technologies, e.g. a Swing application with embedded JavaFX content.
Java Swing[Bearbeiten]
This extension for expecco enables the user interface test automation for Java applications whose user interfaces were created with Swing. The block library contains blocks for controlling and checking Swing user interfaces. This extension also integrates into the expecco GUI Test Extension. This extension supports the development of test sequences.
Hauptmerkmale[Bearbeiten]
- Automatisierte Bedienung und Überprüfung von Swing Benutzeroberflächen
- Gleichzeitige Bedienung mehrerer Anwendungen
- Steuerung von Swing Benutzeroberflächen auf entfernten Zielsystemen
- Steuerung von bereits eigenständig Laufenden Java Anwendungen (keine Änderung am Quell-Code notwendig, Keine Rekompilierung der Anwendung nötig)
- Adressierung der Bedienelemente durch Pfade ähnliche dem XPath
- Zugriff auf Objektebene durch Java Bridge Interface Library möglich
- Integration in die expecco GUI Tests Extension
- Block-Bibliothek mit Aktionen und Überprüfungen für Swing Komponenten
Java SWT[Bearbeiten]
JavaFX[Bearbeiten]
Ab Java 11 ist JavaFX nicht mehr im JDK enthalten. Daher müssen Sie zusätzlich ein JavaFX SDK installieren, z.B. von OpenJFX. Kopieren Sie dann die jar-Dateien aus dem lib-Verzeichnis des JavaFX JDKs nach packages\exept\expecco\plugin\javafx\lib
im expecco-Installationsverzeichnis.
Functionality[Bearbeiten]
The interface establishes a connection to the Java VM and provides functions for reading widget attributes, recording user input, and remotely controlling the application. In addition, a library provides additional building blocks for automating tests. Essentially, the Java Swing plugin consists of two parts, the extension for expecco and the application control (agent). To control the Swing application, an agent is loaded into the Java Virtual Machine of the running Java application. A Java Development Kit 1.8 (JDK) or higher is required to load the agent. However, the application to be tested can be run in a normal Java Runtime Edition 1.8 (JRE).
Requirements[Bearbeiten]
On the computer on which the application to be tested is to run (local or remote):
- Java Development Kit 1.8 oder höher (zum laden des Agents)
- Java Runtime Edition 1.8 oder höher (zur Ausführung der zu testenden Anwendung)
The expecco requirements apply on the expecco computer.
Please note that both the agent and the application to be tested must be started with either 32 or 64 bit Java, otherwise no connection is possible.
Caused by JDK changes between Java versions, potential version conflicts may occur.
The compatibility of the versions is as follows. Weitere Informationen dazu.
Access permissions=[Bearbeiten]
To be able to guarantee a connection on the target system, additional parameters must be specified when starting the application to be tested (as well as the Java agent).
There are two ways to do this
- Set an environment variable that is automatically loaded at the start of each Java application
- Manual transfer of parameters at each start of a Java application
- (Alternatively you can change access rights in the module-info.java files directly, but this is anything but practical)
Up to Java 11 it should be sufficient to set the following parameters:
-Djdk.attach.allowAttachSelf=true
--illegal-access=permit
Setting an environment variable works as follows (Example JDK_JAVA_OPTIONS which is loaded at every JVM start)
for Windows Systems
setx JDK_JAVA_OPTIONS "-Djdk.attach.allowAttachSelf=true; --illegal-access=permit"
- or via the GUI (Windows key + Pause).
- Bash:
export _JAVA_OPTIONS='-Djdk.attach.allowAttachSelf=true; --illegal-access=permit'
- C Shell:
setenv _JAVA_OPTIONS '-Djdk.attach.allowAttachSelf=true; --illegal-access=permit'
As of Java 11 there is a stricter separation for the encapsulation of modules:
--illegal-access=permit
will no longer work if the target application has a fixed module encapsulation (Details).
In this case, additional parameters must be specified at program start which allow Expecco access to the inherent resources.
Depending on the technology used, the required parameters can vary, which is why you have to find them out for yourself.
jdeps list-deps JARNAME.jar
Jdeps is a freely available (part of the jdk) very useful tool for this purpose.
A short overview of the commands can be found here ©
Example JavaFX:
The environment variable PATH_TO_FX
which points to the JavaFX directory must be set (functionality see above)
The following parameters must be available when starting the Java application
Parameter list (fold out)
--modul-path "%PATH_TO_FX%"
--add-modules=javafx.controls
--add-modules=javafx.swing
--add-modules=javafx.web
--add-opens öffnet javafx.graphics/com.sun.javafx.sg.prism=ALL-UNNAMED
--add-opens javafx.graphics/javafx.stage=ALL-UNNAMED
.
--add-opens öffnet javafx.graphics/javafx.scene=ALL-UNNAMED
.
--add-opens javafx.graphicss/com.sun.javafx.stage=ALL-UNNAMED
öffnet.--add-opens javafx.graphics/javafx.scene.layout=ALL-UNNAMED
--add-opens javafx.controls/javafx.scene.control=ALL-UNNAMED
.--add-opens javafx.controls/javafx.scene.control.skin=ALL-UNNAMED
.--add-opens javafx.controls/javafx.scene.chart=ALL-UNNAMED
.--add-exports javafx.controls/com.sun.javafx.charts=ALL-UNNAMED
--add-opens javafx.controls/com.sun.javafx.charts=ALL-UNNAMED
--add-exports javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED
--add-opens javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED
.
--add-opens javafx.graphics/javafx.scene.image=ALL-UNNAMED
--add-opens javafx.graphics/javafx.scene.shape=ALL-UNNAMED
--add-opens javafx.graphics/javafx.scene.text=ALL-UNNAMED
--add-opens javafx.graphics/javafx.application=ALL-UNNAMED
.
--add-opens javafx.graphicss/javafx.geometry=ALL-UNNAMED
.
--add-opens öffnet javafx.graphics/javafx.scene.robot=ALL-UNNAMED
.
--add-exports javafx.graphicss/com.sun.glass.ui=ALL-UNNAMED
--add-opens öffnet javafx.graphics/com.sun.glass.ui=ALL-UNNAMED
--add-opens öffnet javafx.graphics/com.sun.glass.ui.win=ALL-UNNAMED
.
--add-opens javafx.graphics/javafx.scene.input=ALL-UNNAMED
.
--add-opens javafx.base/javafx.event=ALL-UNNAMED
öffnet.--add-exports javafx.base/com.sun.javafx.runtime=ALL-UNNAMED
--add-opens javafx.base/com.sun.javafx.runtime=ALL-UNNAMED
--add-exports javafx.graphicss/com.sun.javafx.scene=ALL-UNNAMED
--add-exports javafx.graphicss/com.sun.javafx.util=ALL-UNNAMED
--add-exports javafx.graphicss/com.sun.javafx.scene.input=ALL-UNNAMED
--add-exports javafx.web/com.sun.webkit.dom=ALL-UNNAMED
If you still get a java.lang.IllegalAccessError
, you have to extend this parameter in the following way:
- Error text of the type
Module <module> does not open "<package>" for unnamed modules
.
--add-opens <modules>/<package>=ALL-UNNAMED
>- Example:
Module java.base does not open java.lang for unnamed module
solve with--add-opens java.base/java.lang=ALL-UNNAMED
.
- Error text of the type
cannot access the class <package>.<class name> (in module <module>), because the module <module> <package> does not export to the unnamed module
.
---add-exports <modules>/<package>=ALL-UNNAMED
>- Example:
cannot access the class com.sun.javafx.scene.input.ExtendedInputMethodRequests (in the module javafx.graphics) because the module javafx.graphics com.sun.javafx.scene.input not exported into an unnamed module
solve with--add-exports javafx.graphicss/com.sun.javafx.scene.input=ALL-UNNAMED
>
Installation on the expecco computer[Bearbeiten]
The Java Swing extension is automatically installed by an installation program in expecco.
If the application to be tested for the development of test sequences is executed on the same computer, it should be started after expecco underExtras => Settings => Extensions => Java Bridge
is the local path to a Java Development Kit 1.8 or higher.
The mandatory setting here is Path to JDK installation
which is used for the main connection.
Path to Java installation
is an alternative setting for Groovy which only requires a JRE.
The Java Agent is automatically started in local connections with these settings.