Java GUI Plugins/en

Aus expecco Wiki (Version 2.x)
Zur Navigation springen Zur Suche springen

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):

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.
JavaSwing Bridge Compatibility.png

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).

Windows Setenvironment.png]

for Unix systems

  • 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

Sollten Sie dennoch einen java.lang.IllegalAccessError erhalten, müssen Sie diesen Parameter in folgender Weise erweitern:

  • Fehlertext der Art Modul <module> öffnet nicht "<package>" für unbenannte Module.
--add-opens <module>/<package>=ALL-UNNAMED >

Beispiel: Modul java.base öffnet java.lang nicht für unbenanntes Modul lösen Sie mit --add-opens java.base/java.lang=ALL-UNNAMED.

  • Fehlertext der Art kann nicht auf die Klasse <package>.<class name> (im Modul <module>) zugreifen, da das Modul <module> <package> nicht in das unbenannte Modul exportiert.
--add-exports <module>/<package>=ALL-UNNAMED >

Beispiel: kann nicht auf die Klasse com.sun.javafx.scene.input.ExtendedInputMethodRequests (im Modul javafx.graphics) zugreifen, da das Modul javafx.graphics com.sun.javafx.scene.input nicht in ein unbenanntes Modul exportiert lösen Sie mit --add-exports javafx.graphicss/com.sun.javafx.scene.input=ALL-UNNAMED>



Copyright © 2014-2024 eXept Software AG