Although we officially do not support Java applet testing, there is a way (or work around as you may call it) to test applets using the 'Swing' application in iTest.
There are a few restrictions and requirements though.
Restrictions
- The applet must be written using Swing. (Most applets are, but there are some old applets which use primitive AWT controls, which we can see in the Swing application, but can not perform complex actions on)
- The applet must be stand-alone, i.e. independent of the web page that is hosting the applet. The applet should not be dependent on data avialble on the HTML content of the page or on some javascript method.
- The URL of the page that his hosting the applet must be directly accessible. For example, it does not take you first to the login page when you enter credentials and only then can you access that page.
- The machine that is running iTest must have Java JDK (5.0 or later) installed. Note that this is JDK, not JRE. Once we officially support applets in iTest, we might add all the JDK libraries and programs required into the built in JRE we ship with iTest. But, for now the machine needs to have JDK installed.
"{JDK home folder}\bin\appletviewer.exe" -J-javaagent:"{Swing resource folder}\SwingTestHarness.jar" -J-Xbootclasspath/a:"{Swing resource folder}\SwingTestHarnessInterfaces.jar;{Swing resource folder}\SwingTestHarness.jar;{Swing resource folder}\xmlwriter-2.2.jar" %1
{Swing resource folder} is the path to the Swing resource plugin folder. This is the folder that is named "com.fnfr.svt.applications.java.swing.resources_xxxxx" in the plugins folder where iTest is installed.
"c:\Program Files\Java\jdk1.6.0_06\bin\appletviewer.exe" -J-javaagent:"C:\Program Files\Fanfare\iTest 3.2\plugins\com.fnfr.svt.applications.java.swing.resources_3.2.0.30861\SwingTestHarness.jar" -J-Xbootclasspath/a:"C:\Program Files\Fanfare\iTest 3.2\plugins\com.fnfr.svt.applications.java.swing.resources_3.2.0.30861\SwingTestHarnessInterfaces.jar;C:\Program Files\Fanfare\iTest 3.2\plugins\com.fnfr.svt.applications.java.swing.resources_3.2.0.30861\SwingTestHarness.jar;C:\Program Files\Fanfare\iTest 3.2\plugins\com.fnfr.svt.applications.java.swing.resources_3.2.0.30861\xmlwriter-2.2.jar" %1
Note that you need to create this batch file only once, and you can just pass in different URLs in the session profile to launch different applets.
Now that we have a batch file, we are ready. Open up iTest to create a new Swing session profile.
Select the radio button that says "Launch a custom application"
In the "Command to launch application", browse to the .bat file that you just created.
In the "Additional command line options" type in the URL of the page that contains the applet.
You are all set. Now you can just start the Swing session, and you will see the AppletViewer load up. Note that it will take more time to load the applet in applet viewer than it would normally take on a web page.
I have attached a sample session profile and test case that loads the applet version of the "SwingSet" Java application most people are familiar with. The applet is hosted on a remote site on the internet, so that just proves that we can test remote applets locally using this setup. My .bat file that i call the appletLauncher is also included in the zip attachment.
(To run the attached ecample, don't forget to update the session profile and .bat file to fit in with your machine's install location)