Skip to main content

Java App Testing

Beginning with version 2.8, Cycle has the ability to interact with Java (Swing) applications. These new Java app Steps allow Cycle to interact with Java applications without relying on desktop steps that are not tied to a specific running application or using image matching.

When to Use Java App Steps

Using Cycle’s Java application steps is the preferred method when testing Java (Swing) applications. The following conditions are good decision points when deciding whether or not to use Java app steps instead of using the traditional desktop steps and image matching:

  • The application you are testing has useful CSS locators that allow you to pinpoint specific elements (text boxes, radio buttons, check boxes, etc…) to interact with on screen.
  • You are developing Cycle features that will locally test a Java application built with Java 8.

Cycle desktop steps and image matching steps will interact with Java applications, but these steps have limits that can result in negative test results. These limits should be taken into consideration when deciding whether or not to use Java app steps instead.

Desktop step limitations:

  • You cannot guarantee the current application in focus on the desktop is the application you are testing. Cycle completes the desktop steps as written. Any key presses, typing, or clicking will continue to happen on the desktop in whatever application is currently running and the test will fail.
  • You cannot guarantee mouse or cursor position on screen when using a feature that was developed on a different system with a potentially different resolution.

Image matching limitations:

  • Screen resolution, themes, and color settings can vary across multiple devices. Images matching on one machine may not match on another machine if all video settings are not identical. These differences will cause tests to fail.
  • Image matching can lead to false negative and positive results depending on the image correlation setting.
  • Visual changes to the application due to a patch or modification may require images to be recaptured for the feature to execute properly.
  • Developing features to run on multiple machines may require multiple libraries of image files.

Desktop steps and image matching can be utilized to test Java applications, but their limitations tend to make them less reliable that terminal steps and web steps. The Java app steps are much more in line with the precision provided by web steps and are the preferred option for interacting with Java applications.

Using Java App Steps

If you are comfortable developing web features using element locators and xPath, then you will be able to use the java app steps without much trouble. Less technically inclined users may find using java app steps a challenge until they are able to become comfortable with evaluating CSS locators and determining how to uniquely identify those objects.

Initial Setup

For Cycle to be able to execute the JavaAppDriver family of Steps, a few system environemnt variables must be established and a Java security permission will need to be added.

  1. To Add and Edit System Wide Environment Variables, start by typing run into the Start Menu or Search box and open the Run Application.

  2. In the Open field type or paste SystemPropertiesAdvanced and click OK or press enter. Advanced System Properties

  3. The System Properties dialog box will open with the Advanced Tab selected. Click on the Environement Variables... button at bottom. Environment Variables

  4. Here we can add the necessary New... entries to the lower list of System variables:

  • JAVA_HOME should point to the version of Java running on the machine, usually located in C:\Program Files\Java\


An additional Environment Variable is required for Cycle versions 2.14 and earlier marathon.agent.file will need to be added and point to the marathon driver that is packaged with Cycle at C:\Program Files (x86)\CycleLabs\Cycle\stage\lib\com.jaliansystems.marathon-java-agent- (depending on your Cycle install location). This Environment Variable is not needed in Cycle versions 2.15 and newer.

New Environment Variables

  1. Finally, after selecting the Path System variable click Edit... and add an entry for %JAVA_HOME%\bin Java Home Path

  2. Once updating these Environment Variables, Cycle will need to be closed and reopened for the Java App Steps to use these values to access the necessary resources.

You will also need to add a security permission to the Java Web Start policy file. You will need Administrator privileges to save changes to the file.

  1. Ensure that the %JAVA_HOME%/lib/security/javaws.policy file exists.

  2. Open Notepad as an Administrator. Run Notepad as Administrator

  3. Open the %JAVA_HOME%/lib/security/javaws.policy file in Notepad. You may need to select the All Files file type for the file to appear. Open javaws.policy file

  4. Ensure the javaws.policy file contains the following snippet. If this snippet is not present, add it to the file. This snippet enables Java to run JNLP files using Java Web Start. There may be other entries in the file for other applications on your system.

grant codeBase "file:${jnlpx.home}/javaws.jar" {
  1. Add the following snippet to the file. This snippet enables JavaAppDriver to interact with Java Web Start applications.
grant codeBase "${marathon.agent}" {
  1. Save the file.

  2. Close and reopen the file to ensure that the file contents are saved to disk. The file should contain the following contents:

grant codeBase "file:${jnlpx.home}/javaws.jar" {

grant codeBase "${marathon.agent}" {
  1. Cycle may need to be closed and reopened for the Java App Steps to run with the proper permissions.