Skip to main content

Automating Java Web Start applications

The Squish for Java edition not only supports testing Java Swing/AWT, SWT/Eclipse RCP or JavaFX based applications but also Java Web Start applications. There are two ways to automate an application started via Java Web Start, either starting it through the tool javaws that is part of the Java runtime or through the web browser. We will look at both of these options after clarifying a few requirements for automating Java Web Start through Squish

Ensuring that the right JRE is being used by Java Web Start

In order for Squish to automate any Java application it has to be configured with the same Java Runtime Environment (JRE) that the application is being executed with. This can be done during the installation process or at a later point using the squishconfig commandline tool that is shipped with Squish.

In the case where multiple JREs are installed on a system, the Web Start launcher will decide which of those installed JREs is being used to launch the AUT (Application Unter Test). In order to ensure that the launcher uses the same JRE that has been configured by Squish it is necessary to disable all other JREs in the Java Control Panel by selecting the 'Java' tab and then clicking on the 'View' button.

The Java Control Panel's list of JREs can also be used to identify the path to specify in Squish's installation or with squishconfig. The path field can be double-clicked and then the text selected and copied out to make sure the right path is passed to Squish.

Finally at this time only Oracle Java 9 and older are still supporting running web start applications. JREs of other vendors or newer versions of Oracle Java are not supporting it anymore. This is not a limitation in Squish but one in the Java Runtime Environment.

Starting the web start application using the javaws tool

When using javaws to start the Web Start application, you can configure the tool javaws (which is included in the Oracle JRE (Java Runtime Environment) installations) as AUT and pass the URL to your Web Start application (the jnlp file) as an argument.
This can be done in the Squish IDE's test suite settings editor.

A few things need to be taken care of to be able to automate a Web Start application successfully:

Setting Maximum Startup Time:

One should make sure that Squish waits long enough for the application to get downloaded and then get started as well. This is done by setting a suitable Maximum Startup Time in the Squish IDE at Edit > Server Settings > Application Behavior. Change the Maximum Startup Time setting to the time your application normally needs plus, say, an extra 30 seconds to allow for temporary extra demand on the machine.
So, for a normal 60 second startup, set the time to 90 seconds.

Setting a Maximum Post-Mortem Wait Time:

The Maximum Post-Mortem Wait Time is the time Squish should wait after the first AUT process has exited. Sometimes the launcher process may exit before the second (the "real") AUT process has been hooked up by Squish. This setting can also be changed under Edit > Server Settings > Application Behavior in the Squish IDE.
This value should be set to twice the time (in milliseconds) between the appearance of the Java Web Start splash screen and the appearance of the application.
For example if that time is 5 seconds, then this value should be set to 10000.

Starting the web start application through the web browser

When a Web Start application is started via a web browser, Squish for Web should be used to automate the web browser to perform the steps that start the Web Start application.
In this case the Web Start application gets hooked automatically by Squish and every user interaction with it is recorded.
A new application context is introduced for the Web Start application. You can use this application context to switch between automating the website in the browser and the webstart application.

It is necessary to enable the 'Enable support for testing Java applets in web pages' during the installation of Squish or using the --support-applets squishconfig tool. Please be aware that the squishconfig tool currently requires specifying the --java parameter alongside --support-applets for the setting to be changed.

Starting the web start application through the browser is currently known to work only when using Microsoft Edge, Google Chrome and Microsoft Internet Explorer as browser. Mozilla Firefox currently does not pass the necessary hooking environment to the Java runtime.

Comments

    The Qt Company acquired froglogic GmbH in order to bring the functionality of their market-leading automated testing suite of tools to our comprehensive quality assurance offering.