Katalon: Sikulix Integration: Problems with JNA --- SikuliX principally works

Asked by Marie Belle Salloum

I'm using the integration of Sikulix into Katalon Studio, I'm doing it as recommended on katalon studio but I'm getting an error:
"ERROR c.k.katalon.core.main.TestCaseExecutor - ❌ Test Cases/DPI_Automation/PcapGeneration/SikuliTest FAILED.
Reason:
java.lang.NoSuchMethodError: com.sun.jna.Native.load(Ljava/lang/String;Ljava/lang/Class;Ljava/util/Map;)Lcom/sun/jna/Library;"

jna version: 5.7.0
sikulix version: 2.5.0

Can you please advise if they are compatible or not, and if not which versions should I choose?

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

Since I do not know the Katalon eco-system, I do not know, in which way you use SikuliX 2.0.5.

- if it is sikulixapi from Maven Central, then it's POM references JNA 5.6.0

- if it is a complete jar including all dependencies (e.g. sikulixide), then it already contains JNA

If you tell me more about what you are doing at the place where you get the error, I could try to help you further.

Revision history for this message
Marie Belle Salloum (mbs88) said :
#2

Hey RainMan,

Katalon is an automation testing tools that uses groovy and selenium in order to create the test cases, so for most of test cases we need to add JNA library as an additional library.

What I'm trying to do is to integrate between Sikuli and Katalon, which is something that can be done as shown in their websites here:
https://docs.katalon.com/docs/katalon-platform/integrations/sikulix

I've added sikulix jar file downloaded here from launchpad, I tried several versions of sikulix with several versions of JNA libraries to check, and they're all giving me the same error.

Can you please advise

Revision history for this message
RaiMan (raimund-hocke) said (last edit ):
#3

That's interesting.

When I had a short look into Katalon yesterday, I did not realize, that they mention SikuliX.
So I decide it is worth to have a deeper look.

If we have a chance to get it to work, then with 2.0.5
But you might as well give the 2.0.6-prefinal a chance. (see below)

I guess your problem is a class-path problem: There seem to be different JNA versions on the classpath.
So at least, you should test with no extra import of JNA.

Test with 2.0.6 (details: https://github.com/RaiMan/SikuliX1):
Use this jar (it is the IDE, but contains the API as well) as the one to be imported:
https://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=com.sikulix&a=sikulixidewin&v=2.0.6-SNAPSHOT&e=jar

reduce the testcase to the minimum script, that produces the error and send me script and additional info to my mail sikulix---at---outlook---dot--com. A stack trace at the crash point would be helpful and a full list of the classpath.

Revision history for this message
Marie Belle Salloum (mbs88) said :
#4

I tried it using 2.0.6, the jar that you added in the link above, it didn't work, it even stopped me from getting the function to work as if I don't have any code lines at all.

the testcase I'm doing is this:

"
import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testng.keyword.TestNGBuiltinKeywords as TestNGKW
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as Windows
import internal.GlobalVariable as GlobalVariable
import org.openqa.selenium.Keys as Keys
import org.sikuli.script.Key as Key
import org.sikuli.script.Screen as Screen
import org.sikuli.script.FindFailed as FindFailed
import org.sikuli.script.ImagePath as ImagePath

ImagePath.add(System.getProperty('user.dir') + '\\Sikuli')

Screen s = new Screen()

s.find('Search.PNG')

s.click('Search.PNG')

"

I had to revert the JNA version to 4.1.0 and sikulix version to 2.0.4 for it to show up as a function.

This is the error log:

"
01-15-2024 04:10:45 PM Test Cases/DPI_Automation/PcapGeneration/SikuliTest

Elapsed time: 4.251s

Test Cases/DPI_Automation/PcapGeneration/SikuliTest FAILED.
Reason:
java.lang.NoSuchMethodError: com.sun.jna.Native.load(Ljava/lang/String;Ljava/lang/Class;Ljava/util/Map;)Lcom/sun/jna/Library;
 at org.sikuli.natives.SXUser32.<clinit>(SXUser32.java:13)
 at org.sikuli.natives.WinUtil.<clinit>(WinUtil.java:495)
 at org.sikuli.script.support.RunTime.addToWindowsSystemPath(RunTime.java:1462)
 at org.sikuli.script.support.RunTime.libsExport(RunTime.java:1403)
 at org.sikuli.script.support.RunTime.libsLoad(RunTime.java:1232)
 at org.sikuli.script.support.RunTime.loadLibrary(RunTime.java:1434)
 at org.sikuli.script.Finder$Finder2.<clinit>(Finder.java:538)
 at org.sikuli.script.Finder$FindInput2.<clinit>(Finder.java:1167)
 at org.sikuli.script.Finder.<init>(Finder.java:34)
 at org.sikuli.script.Region.doCheckLastSeenAndCreateFinder(Region.java:2907)
 at org.sikuli.script.Region.checkLastSeenAndCreateFinder(Region.java:2868)
 at org.sikuli.script.Region.doFind(Region.java:2797)
 at org.sikuli.script.Region.find(Region.java:2275)
 at org.sikuli.script.Region$find.call(Unknown Source)
 at SikuliTest.run(SikuliTest:28)
 at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
 at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
 at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:448)
 at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:439)
 at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:418)
 at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:410)
 at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:285)
 at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:144)
 at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:135)
 at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
 at TempTestCase1705327838862.run(TempTestCase1705327838862.groovy:25)

"

Revision history for this message
RaiMan (raimund-hocke) said (last edit ):
#5

I got both jars to run: API-2.0.5 and IDE-2.0.6

But on the way I had some problems with Catalan Studio:
- could not remove the actual SikuliX lib - had to do it manually outside
- after some errors a Run did not do anything any more - just started and terminated
- after some error situations, the script-tab in the editor did not show anymore

I switched off the "auto restore" on exit.
After having done some changes in the project setup and if the RUN then simply terminated without doing anything, I exited Catalan and started again.
After opening the test case again, I at least succeeded in running some SikuliX features.

my script additions:
------------------------------
import org.sikuli.script.Screen as Screen
import org.sikuli.script.Match as Match
import org.sikuli.script.ImagePath as ImagePath

//System.getProperty('user.dir');
//ImagePath.add does not work: intervening spaces are internally converted to %20 (is surely a SX bug)
String udir = "C:/Users/rmhde/_SXRun";
String images = "/katalon"
System.out.println(udir)

ImagePath.add(udir + images)
//ImagePath.dump("") //only works in 2.0.6

Screen s = new Screen()
s.hover() // moves to screen center

Match m = s.exists("img");
System.out.println(m);

s.click(m.offset(22, 0))
// moves to the wanted location and clicks

System.out.println(s)
-------------------------------------------------------

Conclusion: principally works with 2.0.5 and 2.0.6

Revision history for this message
Marie Belle Salloum (mbs88) said :
#6

I'm trying now with version 2.0.6 as you suggested but it's not working for me now, I'm not able to run the script now.
Can you inform me what settings did you modify? and what type of project did you choose?

Revision history for this message
RaiMan (raimund-hocke) said :
#7

Sorry, but I already removed Katalon from my system. For my possible use cases too complicated (IntelliJ IDEA is enough for me).

If I remember well:
- started a new project (for Windows Desktop?)
- added a new testcase
- in the project settings added the SikuliX jar in the library section
- added my script statements in the test case script tab

... and run the test case

... sometimes having the above mentioned problems and workarounds.

again: I did not extra add the jna-jar in the settings lib section!

hope it helps.

Can you help with this problem?

Provide an answer of your own, or ask Marie Belle Salloum for more information if necessary.

To post a message you must log in.