Sahi - Java GUI Application Automation
abstract
This section details how to test Java Application.
If you are not familiar with Sahi Pro, please see Quick Tutorial on Sahi Pro
If you are not familiar with Sahi Pro, please see Quick Tutorial on Sahi Pro
Introduction
Sahi Pro Desktop Add-on provides support for automation of Java Application.Installation
DownloadSahi Pro
and Sahi Pro Desktop Add-on
from Downloads Archive.Install
Sahi Pro
into a folder without spaces in its path.Then install
Sahi Pro Desktop Add-on
into the same folder as Sahi Pro
.For details about installation please refer here
License
Sahi Pro Desktop Add-on needs a separate license from Sahi Pro.Register here for a 30 day fully functional trial version.
Recording Java Application
- Before the starting the Java application, we need to attach Sahi's agent.
This can be done by passing -javaagent:...agent.jar to the java command which starts your application.
We recommend creating a batch file to invoke your jar file and modifying it like this:
Open the batch file which is being used to run the Java Application. Append the following lines in the batch file:
ChangeSET SAHI_JAVA_AGENT_PATH=<sahi_pro_path>\extlib\sahi\sahiagent.jar SET JAVA_TOOL_OPTIONS=-javaagent:"%SAHI_JAVA_AGENT_PATH%" ... java command to start your application ...
<sahi_pro_path>
accordingly.
- From the Sahi Dashboard, open any browser and launch the Controller.
You can now start recording.
Like normal Sahi, you can use CTRL-Hover to identify various elements on the Java Application.
info
Security Settings
If the web start application is not behaving as expected, you might need to set Java security settings as follows:
If the web start application is not behaving as expected, you might need to set Java security settings as follows:
- Find the
<JAVA_HOME>\lib\security\java.policy
file. - Edit the file with these settings:
grant {
...
... Existing permissions ...
...
permission java.security.AllPermission;
};
Scripting Notes
-
To start a Java application from script, use
_execute("correct/path/your_application.bat");
- All code interactions with Java application will need to be preceded by _setMode("JAVA")
-
For executing Java application only scripts, use "generic" as Start Mode, and use _setMode("JAVA") at the start of script.