18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

Calling java function from SAHI

vinu32vinu32 Members
edited November -1 in Sahi - Open Source
Hi -

OS Name - windows 7
Browser Name - IE 8
Sahi build - 3.5

I am trying to automate a swing application which is part of our test process. This swing app is called from the web app. We have automated the web app part using SAHI and now trying to automate the swing application. For this we are using sikuli APIs and i have written a java function which uses the sikuli apis to test the swing app. I have tested the function and it works fine inside my eclipse IDE.

Now when i try to integrate this with SAHI it does not work.

the SAHI code looks like ---
var swingapp= new Packages.com.sahi.swing();
var $flag = swingapp.completeCase($caseId);

swing is the java object and completeCase is the java function which uses sikuli to automate the swing application.

java code ----
public boolean completeCase(String caseId) throws AWTException, FindFailed{

logger.debug("Inside the completeCasefunction");
Screen scr = new Screen();
SikuliScript script = new SikuliScript();

//first open the browser
logger.debug("Going to open the browser");
script.openApp("c:\\Program Files\\Internet Explorer\\iexplore.exe");
scr.wait("images/WindowsInlcm.png", 10);
scr.type("https://staging.fadv.com/screendirect/index.do\n";);
scr.wait("images/1311918169978.png",100);
scr.type("username\t");
scr.type("paswword\n");
scr.wait("images/WelcometoScr.png",20);
.......
}

The Sikuli script above uses native calls and hence SAHI is not able to call them. I modified sahi.bat to add SET SIKULI_HOME=D:\Program Files (x86)\Sikuli X.
When i run it from command prompt i get the following error --
Exception in thread "main" java.lang.UnsatisfiedLinkError: D:\Program Files (x86
)\Sikuli X\libs\Win32Util.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1778)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1674)
at java.lang.Runtime.load0(Runtime.java:770)
But the above error is not because of SAHI.

any help will be highly appreciated.

thanks
Vinod

Comments

  • Hi Narayan -

    Your reply would be highly appreciated since we are completely stuck and cannot proceed further. I have tried all that i could with my SAHI skills and am looking for your help.

    Thanks
    Vinod
  • narayannarayan Administrators
    Hi Vinod,

    I am not sure either what the problem is here. Give me a day and I will see if I can get Sikuli working with Sahi.

    Regards,
    Narayan
  • narayannarayan Administrators
    Hi Vinod,

    Try to get the Sikuli script working outside of eclipse and working out of a standalone Java class, invoked from a command line. That should help you figure out the error.

    Regards,
    Narayan
  • Narayan -

    I pasted the error to show you that there are native calls made from the sikuli APIs. My java function works outside of eclipse and inside eclipse. But when i try to call if from sahi script it does not show any error.
    I was asking you if the sahi controller can invoke the win32util.dll inside the sikuli libs folder. Not sure how the the sahi controller behaves with native libs. That should probably solve my problem.

    thanks
    Vinod
  • narayannarayan Administrators
    Hi Vinod,

    Sahi scripts execute as if they are part of a java program. The controller does not have any role in this. The required classes need to be in Sahi's class path. That is all.

    It is possible that Sikuli needs the other dlls to be in the PATH. Since Sahi executes from sahi/userdata/bin, Sikuli may not be finding the other dlls. Make sure that you modify the correct batch file. If you start using dashboard, modify in start_dashboard.bat; if you are using sahi.bat, modify there.

    Add this to the start of the correct bat file.

    SET SIKULI_HOME=D:\Program Files (x86)\Sikuli X
    SET PATH=SIKULI_HOME\libs;%PATH%

    Check if your error goes away.

    Regards,
    Narayan
Sign In or Register to comment.