Java Add-in

This topic introduces UFT One's Java Add-in, used to test Java user-interface objects (controls), in environments such as Internet Explorer, Mozilla Firefox, Java Web Start, Applet Viewer, and in standalone Java applications.

Java Add-in support references

The Java Add-in provides customized Java test objects, methods, and properties that can be used when testing objects in Java applications.

For details, see the Java section of the UFT One Object Model Reference for GUI Testing.

Tip: If your controls are not supported out-of-the-box by UFT One, develop your own support. For details, see Java Add-in Extensibility.

For more details, see:

Back to top

Java Add-in prerequisites

The following table lists prerequisites that may be required before using UFT One to test Java applications.

Opening Your Application

If you cannot open your Java application after starting UFT, you may have a memory fragmentation issue. Check your memory settings, and see Memory issues.

Testing Java applets in a Web browser

When testing Java applets in a Web browser, if your tests include operations on Web test objects, you must load the Web Add-in as well as the Java Add-in.

In such cases, use the Web tab of the Record and Run Settings dialog box to specify your record and run preferences.

Include all Java modules required by your application

If your application requires Java modules that are not included by default, make sure that the command you use to run your application includes and opens the relevant modules.

Include the following in the start command:

--add-modules={all modules required by your application} --add-opens {specify opens for modules if required}

Object identification in Java 16 or later (AWT, Swing and SWT)

For UFT One to identify Java objects in Java 16 or later (using Oracle JDK, OpenJDK, or Zulu OpenJDK ), you must include and open the following modules and packages when you run your Java AWT, Swing or SWT applications:

--add-modules=java.desktop --add-opens java.desktop/sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.awt.image=ALL-UNNAMED --add-opens java.desktop/java.awt=ALL-UNNAMED

You can specify these options in one of the following ways: 

  • Include the options in the Java command that you use to run your application.

  • Enter the options in the value of the JDK_JAVA_OPTIONS environment variable. Note that this affects all Java applications that you run on this machine.

Note: For working with JavaFX applications see JavaFX applications instead.

Back to top

Java Add-in configuration

The following table describes where to find UFT One configuration options related to Java testing:

UFT One Options

Use the Java pane.
(Make sure that a GUI test is open and select Tools > Options > GUI Testing tab > Java node.)

Record and Run Settings

Use the Java tab.
(Record > Record and Run Settings)

For details, see Java Tab (Record and Run Settings Dialog Box).

Test Settings

Use the Java pane.
(File > Settings > Java node)

For details, see Java Pane (Test/Business Component Settings Dialog Box / Application Area - Additional Settings Pane).

Custom Active Screen Capture Settings

Use the Java section.
(Tools > Options > GUI Testing tab > Active Screen node > Custom Level)

For details, see Active Screen Pane (Options Dialog Box > GUI Testing Tab).

Application Area Additional Settings

Use the Java pane.
In the application area, select Additional Settings > Java in the sidebar.

For business components, the settings displayed in this pane are read-only. To change the Java pane settings for a business component, open its associated application area and use the application area's Additional Settings > Java pane.

For details, see Java Pane (Test/Business Component Settings Dialog Box / Application Area - Additional Settings Pane).

Back to top

JavaFX applications

When working with JavaFX applications, we recommend using jre8_u60 or above. For details, see https://bugs.openjdk.java.net/browse/JDK-8086098.

In addition, depending on the Java version you are using, the following prerequisites apply:

Note: If you are working with Java 8 make sure that you have a minimum Java version of 8.0.1010.13.

Java 11 or later: For UFT One to identify Java objects, perform the following steps on the computer running your application:

  1. Download the JavaFX module and store it locally.

    Caution: Make sure the path in which you store the JavaFX module does not contain any spaces.

  2. Set the following environment variable:

    PATH_TO_FX = <JavaFX module location>\lib.

  3. Add %PATH_TO_FX% to your path.

    You can do this separately or by adding this option when you run your JavaFX applications:

    --module-path="%PATH_TO_FX%"

  4. Include the following modules and packages when you run your JavaFX applications:

    Note: The syntax displayed here for setting the module path applies to setting it in the start javaw command.

    Java 11 - 15:

    --module-path="%PATH_TO_FX%" --add-modules=javafx.controls,javafx.fxml,javafx.base,javafx.swing,javafx.media --add-opens javafx.graphics/com.sun.glass.ui=ALL-UNNAMED --add-opens javafx.base/com.sun.javafx.event=ALL-UNNAMED --add-opens javafx.graphics/com.sun.javafx.stage=ALL-UNNAMED --add-opens javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED --add-opens javafx.base/javafx.event=ALL-UNNAMED --add-opens javafx.graphics/javafx.stage=ALL-UNNAMED --add-opens javafx.graphics/javafx.scene=ALL-UNNAME

    Java 16 or later:

    --module-path="%PATH_TO_FX%" --add-modules=javafx.controls,javafx.fxml,javafx.base,javafx.swing,javafx.media,java.desktop --add-opens javafx.graphics/com.sun.glass.ui=ALL-UNNAMED --add-opens javafx.base/com.sun.javafx.event=ALL-UNNAMED --add-opens javafx.graphics/com.sun.javafx.stage=ALL-UNNAMED --add-opens javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED --add-opens javafx.base/javafx.event=ALL-UNNAMED --add-opens javafx.graphics/javafx.stage=ALL-UNNAMED --add-opens javafx.graphics/javafx.scene=ALL-UNNAMED --add-opens java.desktop/sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.awt.image=ALL-UNNAMED --add-opens java.desktop/java.awt=ALL-UNNAMED --add-opens javafx.controls/javafx.scene.control.cell=ALL-UNNAMED

You can specify these options in one of the following ways: 

Command line

Include the add-modules and add-opens options in the Java command that you use to run your application.

start javaw --module-path="%PATH_TO_FX%" --add-modules={relevant modules} --add-opens {relevant packages per module} -jar <Application_Name>.jar

 

Batch file

Launch the application from a batch file instead of using a command line:

In the folder containing your application's .jar file, create a .bat file containing the following command: 

start javaw --module-path="%PATH_TO_FX%" --add-modules={relevant modules} --add-opens {relevant packages per module} -jar <Application_Name>.jar

Example (Java 16 or later):

start javaw --module-path="%PATH_TO_FX%" --add-modules=javafx.controls,javafx.fxml,javafx.base,javafx.swing,javafx.media,java.desktop --add-opens javafx.graphics/com.sun.glass.ui=ALL-UNNAMED --add-opens javafx.base/com.sun.javafx.event=ALL-UNNAMED --add-opens javafx.graphics/com.sun.javafx.stage=ALL-UNNAMED --add-opens javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED --add-opens javafx.base/javafx.event=ALL-UNNAMED --add-opens javafx.graphics/javafx.stage=ALL-UNNAMED --add-opens javafx.graphics/javafx.scene=ALL-UNNAMED --add-opens java.desktop/sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.awt.image=ALL-UNNAMED --add-opens java.desktop/java.awt=ALL-UNNAMED --add-opens javafx.controls/javafx.scene.control.cell=ALL-UNNAMED -jar JavaFX.jar

Save the .bat file and run it.

Environment variable

Enter the add-modules and add-opens options in the value of the JDK_JAVA_OPTIONS environment variable.

Note that this affects all Java applications that you run on this machine.

Note: The syntax for setting the module path in an environment variable differs slightly from setting it in the start javaw command:

Example (Java 16 or later):

JDK_JAVA_OPTIONS = --module-path %PATH_TO_FX% --add-modules=javafx.controls,javafx.fxml,javafx.base,javafx.swing,javafx.media,java.desktop --add-opens javafx.graphics/com.sun.glass.ui=ALL-UNNAMED --add-opens javafx.base/com.sun.javafx.event=ALL-UNNAMED --add-opens javafx.graphics/com.sun.javafx.stage=ALL-UNNAMED --add-opens javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED --add-opens javafx.base/javafx.event=ALL-UNNAMED --add-opens javafx.graphics/javafx.stage=ALL-UNNAMED --add-opens javafx.graphics/javafx.scene=ALL-UNNAMED --add-opens java.desktop/sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.awt.image=ALL-UNNAMED --add-opens java.desktop/java.awt=ALL-UNNAMED --add-opens javafx.controls/javafx.scene.control.cell=ALL-UNNAMED

Back to top

See also: