To make automation available for Java AWT/Swing applications and applets in Ranorex, there is a new and currently experimental Java Plug-In available for download.
Setting up the Java Plug-In
- First of all close all Ranorex Tools, download the Ranorex 2.3.5 Java Plug-In (zip) (this requires Ranorex 2.3.5 or later) or the Ranorex 3.0 Java Plug-In (zip) and extract it.
- Now you have to determine the path of your active Java runtime Environment to know where to copy the necessary files to. Open the Java Runtime Environment Settings which can be found in “Java Control Panel” (Control-Panel -> Java). There you can see the path of your Java Runtime Environment. If you have more than one Java Runtime Environment installed on your machine, check which one will be used to execute your Java applications by determining which one is activated. If you are using Windows XP SP2, please install Windows Update KB884020.
- After identifying the path you have to copy each of the following files to its corresponding directory based on the root folder of your java runtime installation (e.g. “C:Program Files (x86)Javajre6”):
- “accessibility.properties” to lib
- “RanorexAutomation.jar” to libext
- “JavaHelper32/64.dll” to bin
- After that, copy the file “Ranorex.Plugin.Java.dll” into the Ranorex Plugin directory (“C:Documents and SettingsAll UsersApplication DataRanorex2Plugins” for Windows XP or “C:ProgramDataRanorex2Plugins” for Vista, 7 for Ranorex 2.3. For Ranorex 3.0 choose the Ranorex3 folder instead of the Ranorex2 folder).
- Start Ranorex Spy and check if the Java Plug-In was successfully loaded. Therefore, please open the About Dialog by clicking the Ranorex Logo and check if the Java Plug-In is loaded.
- Start your Java application and Spy. Now you should be able to track the controls of your application under test.
Java Plug-In Example Project
After assuring that the Java plug-In is working as expected it’s now time to start with a simple test project on a Java application.
As application under test we will take a small unit converter test application which can be found here: Converter.jnlp.
Create a new Project in Ranorex Studio and start the application under test by adding following line of code in Program.cs before your recording will be started.
After that copy the application to your project folder and manually start it.
Start a recording on the Application and:
- Slide the “Metric System” slider (marked in red) down.
- Validate the text held by the text field in the “U.S. System” area (marked in orange).
- Validate the slider value of the “U.S. System” slider (marked in green).
- Enter the “Metric System”, remove the given value and replace it with the value 100 (marked in yellow).
- Change the Unit held by the combo box in “Metric System” area from Centimeters to Meters (marked in blue).
- Validate that the text held by the text field in the “U.S. System” area equals to 3.937,01.
- Validate that the slider value of the “U.S. System” slider equals to 3.937.
After recording close the application under test, compile your project and start you compiled project.
Ranorex should be able to automate and validate this Java Swing Application and the generated Ranorex Test Report should look something like this: