Need help in Automation of Java Swing Desktop Application

Hi Everyone,

I need to automate a Java Swing based Desktop Application using Robot Framework. I am trying to configure Swing Library using pip install robotframework-swinglibrary but I am getting error

ERROR: Could not find a version that satisfies the requirement robotframework-swinglibrary (from versions: none)
ERROR: No matching distribution found for robotframework-swinglibrary.

Kindly provide support for installing and configuring swing library on window 10 system and some simple example with Python or Java for automation script of Java swing Application.

Any help and suggestion is much appreciated.

Thanks and Best Regards,
Nidhi Kashyap

Searching the Internet shows the project page, it should be the best place to start.

swing library is java package which can’t be installed or used directly with via pip. Do check out https://github.com/robotframework/remoteswinglibrary - it provides a python wrapper and installation instructions.

Thank you very much for the guidence.
I managed to set remoteswinglibrary in my CLASSPATH env variable. I am running my robot file using python in Pycharm IDE.
I was able to launch simple Java Swing application through python by command

robot swingAppDemo.robot
Below is a simple example code snippet.
*** Settings ***
Library RemoteSwingLibrary

*** Test Cases ***
My Test Case
Start Application com.demo.SwingApp java -jar SwingExe.jar
Select Window MySwing Application
Push Button click
System Exit


It was running fine for one of my Swing Applications but when I changed my application and tried running another jar file by just replacing the jar file in the Star Application ( I also added the new jar file for another swing application in CLASSPATH env variable) I am getting below error:

My Test Case | FAIL |
RemoteSwingLibraryTimeoutError: Agent port not received before timeout

Kindly suggest to resolve this issue.
Thanks in advance.

Hi All,

I have managed to resolve the above issue.
But I am now stuck with another issue while I run my robot file.

My Test Case | FAIL |
org.netbeans.jemmy.TimeoutExpiredException: Wait for “click” subcomponent to be displayed

Inorder to resolve this I have added a line in my code Set Jemmy Timeout TimeoutExpiredException 10

But I am still getting the same error.

So I am suspicious if my code is not navigating to ’ click component ’ where I am getting TimeoutExpiredException .

============================================
I wanted to know which all Spy tools can we use to locate the swing components. I am not able to download the swing explorer launcher.
Although I have added the swag.jar and swexpl.jar in my class path.

I am currently using Access Bridge Explorer.

Also I wanted to know how to identify the components which does not have Name property. Can we use other identifiers other than name such as “Role” to identify the component ?

How can we locate the unique components when name or other property are same in most of the components

Thanks for support in advance.

Best Regards,
Nidhi

Please find my piece of code:

*** Settings ***
Library RemoteSwingLibrary

*** Test Cases ***
My Test Case
Start Application com.demo.SwingApp java -jar SwingExe.jar
Select Window MySwing Application
Set Jemmy Timeout TimeoutExpiredException 10
Type Into Textfield Employee Name nidhi
Set Jemmy Timeout TimeoutExpiredException 10
Type Into Textfield Employee ID 123
Set Jemmy Timeout TimeoutExpiredException 10
Push Button click
System Exit

I have added several timeouts for each component but still I am getting error:

My Test Case | FAIL |
org.netbeans.jemmy.TimeoutExpiredException: Wait for “Employee Name” subcomponent to be displayed

I have also attached screenshot of Access Bridge Explorer where I am locating the elements.
Please help me identifying the components which does not have name property or any unique property

Screenshot very clearly points out that the name property of the component is empty. There is however the name that you might think could be used as a locator (name with jaws algorithm but its not supported by jemmy). Documentation in https://robotframework.org/SwingLibrary/SwingLibrary.html clearly says that when using name string, components name has to be set with setName() method of the component and its very obvious that this criteria is not met as the screenshot points out that the name is not set to anything.

  1. Talk to your developers to set the names for needed components.
  2. Hack jemmy to support other properties as locators.
  3. Use indexes, information in Locating components in the swing library keyword documentation. Not Adviced.

Hi, you need to set classpatch the pyton to patch your library.
So, firstly you need to dowloaf the library:Remoteswinglibrary


Then, you set:
set PYTHONPATH=%PYTHONPATH%;C:\patch\remoteswinglibrary-2.2.4.jar

Import the library in settings:
Library RemoteSwingLibrary

and create your test =)