Java GUI Plugins/en: Unterschied zwischen den Versionen
Ani (Diskussion | Beiträge) (→FAQ) |
Ani (Diskussion | Beiträge) (→FAQ) |
||
Zeile 243: | Zeile 243: | ||
*'''I can't connect but all settings are correct''' |
*'''I can't connect but all settings are correct''' |
||
Even if this should not happen in general, here are a few aspects that can influence the connection. |
: Even if this should not happen in general, here are a few aspects that can influence the connection. |
||
::{| |
::{| |
||
|FIREWALL |
|FIREWALL |
Version vom 18. April 2019, 14:41 Uhr
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.
expecco GUI Browser[Bearbeiten]
The expecco GUI-Browser is an additional 'tool' which offers the possibility to analyze running applications and to develop test sequences. Then you can use the information, such as names and properties of individual elements, to perform actions with the function library or to interact with individual elements.
Connection Establishment =[Bearbeiten]
The following is a short series of pictures that can be used as a 'guide when setting up a connection
]
First you select the option Java
(red circle) via the GUI Browser
(black circle) in the tab Connect
.
In the opening dialog you can now choose between 3 options.
- 'Start application on local machine
provides a convenient way to start a local Java application via command line command - Connect to a running application on the local machine
Allows connection to locally running Java applications
The Java Agent is automatically started with the Java version you specified in the Expecco settings. - Connect to a running application on another machine
Allows you to connect to an already started Java Agent on another machine
This will then connect to the Java application running there.
]
A search for Java applications lists all running Java virtual machines on the target system
.
(in the example: localhost). A selection of the individual entries lists further information about the respective application.
]
If a connection has been successfully established, it will automatically be entered in the Expecco configuration list.
There you can also see the GUI structure of the application as a hierarchical tree.
Information on how to proceed can be found here: GUI Test Reference
]
If you want to re-establish a connection to a previously connected application, you can do this in the dialog box by right-clicking on the entry.
If you have restarted the application (or, in the case of a remote system, the agent) in the meantime, you may have to reestablish the connection.
Connection to remote systems[Bearbeiten]
]
To establish a connection remotely, the Java Agent must first be started on the target computer.
To do this, navigate to the directory ...\exept\bridgeFramework\javaBridge\javaBin
on the computer.
There is a script which automatically detects the Java version in JAVA_HOME and starts the correct agent.
- Windows users start
startAgentLoader.bar
- UNIX users start
startAgentLoader.sh
These scripts can be provided with parameters via the command line as shown in the picture.
-ip <HostnameOderIP>
gives the agent a special IP to wait for a connection. Useful for specific network masks.
Default host is 0.0.0.0.-port >PortNumber
gives the agent a specific port to wait for connections from Expecco.
default port is 56784.
Warnings[Bearbeiten]
If any problems occur with the applications in this list, as can be seen in the picture above,
the connection dialog automatically returns a suggested solution.
If the error that occurs would make a connection impossible, the corresponding entry is automatically marked as invalid.
The following error messages may occur and can be easily corrected:
JAVA VERSION MISMATCH As you can see in the picture, there may be Java version conflicts between the agent and the application.
In this case it is easiest to adjust the Expecco settings for Java Bridge.
A remote connection would have to start the program manually with the desired Java version instead.
The Java Agent, if called via thestartAgentLoader
script, selects the version Based onJAVA_HOME
on the remote system32 BIT - 64 BIT CONFLICT The 32 and 64 bit versions of Java are not compatible with each other.
Both the agent and the application must be started with the same "bit version" of Java.
UNABLE TO DETERMINE VERSION The agent cannot determine which Java version the application is using.
A connection may be possible, but there may be a potential version conflict.
Cross-technology connections[Bearbeiten]
If an application uses multiple Java technologies, you only need to establish one connection and then use the blocks from the library according to the technology of the element to be addressed.
Embedded JavaFX in Java Swing[Bearbeiten]
If JavaFX is embedded in a Swing application, it contains a JFXPanel element. In the GUI browser, the JavaFX elements are displayed below this panel. For the FX blocks to find these embedded FX elements, the block Set FX Context To Panel from the Swing Library with the path to the JFXPanel must be executed at the beginning.
WebView in JavaFX[Bearbeiten]
If a WebView is included in JavaFX, its elements are displayed in the GUI browser below the WebView element. For these elements there are separate blocks in the JavaFX library, which are combined in the folder Embedded WebView. In order for the elements to be found in the test, the block Set WebView Context must first be executed on the element WebView.
Embedded Java Swing in JavaFX[Bearbeiten]
If Java Swing is embedded in a JavaFX application, it contains a SwingNode element. In the GUI browser, its content is still displayed parallel to the FX content. The modules of the Swing library can be used directly with these elements.
JavaSwingLibrary[Bearbeiten]
Example[Bearbeiten]
FAQ[Bearbeiten]
- The tree in the GUI browser does not show all elements of my application'
- An application consists of many different elements. Some of them are not interactive, i.e. they are not directly visible to the user and are only used for formatting, such as panels. The presence of such elements leads to the fact that the tree can become very large and deep. Since these elements are usually uninteresting for automation, they are hidden in expecco by default.
- If in your case you want to access one of these elements or need it to create a unique path, you can change this behavior. The JavaSwingLibrary contains the Set Skip Mode block for this purpose. Four modes can be selected:
INTERACTIVE Collect only interactive elements ALL Collect all elements INTERACTIVE_HYBRID like INTERACTIVE, but with the fallback to ALL if a path cannot be resolved ALL_HYBRID like ALL, but with the fallback to INTERACTIVE if a path cannot be resolved
- Executing the block changes the behavior for the current connection. It refers to what is displayed in the tree as well as how the paths on the blocks are handled.
- I can't connect but all settings are correct
- Even if this should not happen in general, here are a few aspects that can influence the connection.
FIREWALL The firewall can interfere with the Java Agent's communication with the application.
Either you set up an exception rule for the agent or you deactivate the firewall for the duration of the test.I'VE GOT A NEW ONE HERE. It can happen, especially when debugging, that a previous instance of a Java agent was not closed correctly. This can lead to it occupying the socket and rejecting other connections.
AboutExtrax => Error analysis => Close all bridge connections / Close all socket connections
previous instances will be removed.
Please note that this will also close all other existing (local) Expecco connections. In the case of Remote, a restart of the agent and possibly of the application should help.