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

Initial Setup

For Cycle to be able to execute the JavaAppDriver family of Steps, a few system environemnt variables must be established.

  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\
  • marathon.agent.file will need to be added and point to the marathon driver that is packaged with Cycle at C:\Program Files (x86)\TryonSolutions\Cycle\com.jaliansystems.marathon-java-agent-5.4.0.0.jar (depending on your Cycle install location)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.

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 as a challenge until they are able to become comfortable with evaluating CSS locators and determining how to uniquely identify those objects.