September 28, 2022 · 2 min read
Java is an extremely popular programming language that is used to create many desktop GUI applications. It has become a typical demand to automate these Java GUI applications. Clicknium is perfectly suited to the task.
This blog takes SwingSet.jar as an example to introduce how to use Clicknium to automate Java application.
Let’s start to learn about Java automation by automating SwingSet.jar.
Development tools preparation
1. Install Visual Studio Code
2. Install Clicknium extension in Visual Studio Code
Welcome Page to set up the environment.
3. Install Java autoamtion extension
Click the “Install” button, and a confirmation dialog box will pop up. Click “Yes” to confirm. Get the result of the Java extension installation status in the OUTPUT tab of Visual Studio Code.
Create Sample Project
In Visual Studio Code, press Ctrl+Shift+P to open Command Palette, and then type “Clicknium:Sample” to create a sample project.
After choosing a project path and creating the sample project, click on the sample.py file. Press F5 to run it and start to learn the Clicknium automation.
Recording UI elements
1. Click the Capture button to record UI elements
The recorder will recognize the Java application automatically and highlight the UI element when the mouse hovers over the element. Press Ctrl+Click on the target element and the relevant locator will be captured.
For more details,please refer the Clicknium Recorder.
2. API Usage
Clicknium API provides an automation programming interface to automate Web, Desktop, SAP, and other applications. The following functions demonstrate Java automation.
Java Automation Sample Code
from time import sleep
from clicknium import clicknium as cc, locator,ui
if __name__ == "__main__":
Java application automation can be very easy with Clicknium.