[1.0.1] Can't run tests via ant script and batch file

Asked by J

My team and I have written a robust framework using Sikuli and Java in Eclipse, using the Sikuli version downloaded from the jar here https://launchpad.net/sikuli/sikulix/1.0.1. We are trying to get tests running automatically via Windows scheduler every night, and to do that we decided to use Apache Ant scripts to run a suite of tests. This Ant script works perfectly fine if run from Eclipse, however I am having issues with creating a batch file to run this Ant script. Here's the contents of my batch file:

---

@echo off
setlocal
set ECLIPSE=C:\Program Files\eclipse
set WORKSPACE=C:\Users\tester\Documents\workspace\Automated-Tests
set BUILDFILE=C:\Users\tester\Documents\workspace\Automated-Tests\buildfiles\core_pages_browser.xml

set ANT_HOME=C:\apache-ant-1.9.4
set JAVA_HOME=C:\Program Files\Java\jdk1.7.0_55
set SIKULI_HOME=C:\Sikuli
set PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin;%SIKULI_HOME%
set CLASSPATH=%JAVA_HOME%\lib

cd C:\Users\tester\Documents\workspace\Automated-Tests

call ant -buildfile buildfiles\core_pages_browser.xml

pause

---

When I run this batch file, I get the following errors from Sikuli:

[junit] [error] ResourceLoaderBasic: checkLibsDir: libs dir is not on system path: C:\Sikuli\libs
[junit] [action] ResourceLoaderBasic: checkLibsDir: Please wait! Trying to add it to user's path
[junit] [info] runcmd: reg QUERY HKCU
[junit] [info] runcmd: reg QUERY HKEY_CURRENT_USER\Environment /v PATH
[junit] [error] ResourceLoaderBasic: checkLibsDir: Logout and Login again! (Since libs folder is in user's path, but not activated)
[junit] [error] Terminating SikuliX after a fatal error! Sorry, but it makes no sense to continue!

---

I have restarted this machine a number of times, and I have also tried logging out and in again but I see this error every single time. Any ideas as to what I can try to make this work? Let me know if you need any more information. Thank you.

Question information

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

beginning with version 1.0.1 it is
SIKULIX_HOME

Revision history for this message
J (jill-freeman) said :
#2

Hi RaiMan,

Thanks for the quick reply. I changed all references from "SIKULI_HOME" to "SIKULIX_HOME" (including in my environment variables) and I am still getting the exact same error. Here's a part of my Ant script in case this helps diagnose the problem:

<target name="compile" depends="clean">
 <javac source="1.7" srcdir="${src}" fork="no" destdir="${bin}" includeantruntime="false">
  <classpath>
   <pathelement path="${src}"/>
   <fileset dir="${lib}">
    <include name="**/log4j*.jar"/>
    <exclude name="**/sikuli*.jar" />
   </fileset>
   <fileset dir="C:/Program Files/eclipse/plugins/org.junit_4.11.0.v201303080030">
    <include name="*.jar"/>
   </fileset>
   <fileset dir="C:/Program Files/eclipse/plugins">
    <include name="*.jar"/>
   </fileset>
   <fileset dir="C:/Sikuli">
    <include name="*.jar" />
   </fileset>
  </classpath>
 </javac>
</target>
<!-- Run the tests -->
<target name="exec" depends="compile">
 <junit printsummary="yes" haltonfailure="no" dir="C:/Users/tester/Documents/workspace/Automated-Tests" showoutput="yes">
  <classpath>
   <pathelement location="${bin}" />
   <fileset dir="${lib}">
    <include name="**/*.jar" />
    <exclude name="**/sikuli*.jar" />
   </fileset>
   <fileset dir="C:/Program Files/eclipse/plugins/org.junit_4.11.0.v201303080030">
    <include name="*.jar" />
   </fileset>
   <fileset dir="C:/Program Files/eclipse/plugins">
    <include name="org.hamcrest.core_1.3.0.v201303031735.jar" />
   </fileset>
   <fileset dir="C:/Sikuli">
    <include name="*.jar" />
   </fileset>
  </classpath>

---

Thank you!

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

Uuups just realized: must be

set PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin;%SIKULIX_HOME%\libs

Revision history for this message
J (jill-freeman) said :
#4

I just changed the "set PATH" command to add "\libs" at the end, and I restarted my computer just to make sure I get a clean start. Here's the message that I get now:

[junit] [error] ResourceLoaderBasic: loadLib: Fatal Error 110: loading: WinUtil.dll
[junit] [error] ResourceLoaderBasic: loadLib: Since native library was found, it might be a problem with needed dependent libraries
[junit] C:\Sikuli\libs\WinUtil.dll: Can't find dependent libraries
[junit] [error] ResourceLoaderBasic: loadLib: Check, wether a valid Sikuli libs folder is in system path at runtime!

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

possible, to add a java runtime parameter:
-Dsikuli.debug=3

to get some more debugging output from Sikuli

Revision history for this message
J (jill-freeman) said :
#6

Apologies, but I'm not quite sure how to do this. This is what I have and it isn't working:

---

@echo off
setlocal
set ECLIPSE=C:\Program Files\eclipse
set WORKSPACE=C:\Users\tester\Documents\workspace\ProView-Automated-Tests
set BUILDFILE=C:\Users\tester\Documents\workspace\ProView-Automated-Tests\buildfiles\core_pages_browser.xml

set ANT_HOME=C:\apache-ant-1.9.4
set JAVA_HOME=C:\Program Files\Java\jdk1.7.0_55
set SIKULIX_HOME=C:\Sikuli
set PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin;%SIKULIX_HOME%\libs
set CLASSPATH=%JAVA_HOME%\lib

cd C:\Users\tester\Documents\workspace\ProView-Automated-Tests

java -Dsikuli.Debug=3 -jar "%SIKULIX_HOME%\sikuli-java.jar"

call ant -buildfile buildfiles\core_pages_browser.xml

pause

---

I'm getting "no main manifest attribute, in C:\Sikuli\sikuli-java.jar" at the top of the command line when I execute the batch file. Thanks for your help with this.

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

java -Dsikuli.Debug=3 -jar "%SIKULIX_HOME%\sikuli-java.jar"

does not make any sense in your command file.

you want to run some test that seem to be located in C:\Users\tester\Documents\workspace\ProView-Automated-Tests

It seems you are using some Eclipse stuff, to achieve this.

So you have to find out, how to add Java parameters to the javaw call that is finally triggered to run your stuff.

Since I do not have any idea, what you are doing, we have some deadlock otherwise ;-)

Revision history for this message
J (jill-freeman) said :
#8

I'm still working on getting -Dsikuli.Debug=3 working, but I tried running a more simple Ant script and this is the error that I get:

java.lang.UnsatisfiedLinkError: C:\Users\tester\AppData\Local\Temp\tmplib\Win32Util.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1965)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1890)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1851)
at java.lang.Runtime.load0(Runtime.java:795)
at java.lang.System.load(System.java:1062)
at com.wapmx.nativeutils.jniloader.NativeLoader.loadLibrary(NativeLoader.java:44)
at org.sikuli.script.Win32Util.<clinit>(Win32Util.java:19)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at org.sikuli.script.Env.getOSUtil(Env.java:91)
at org.sikuli.script.App.<clinit>(App.java:9)
at com.util.appfactory.ProViewAppBrowser.launchBrowserApp(Unknown Source)
at com.util.appfactory.ProViewAppBrowser.startApp(Unknown Source)
at com.util.helpers.TestBase.setUp(Unknown Source)
N/A

java.lang.NullPointerException
at com.util.helpers.BaseObject.hover(Unknown Source)
at com.util.appfactory.ProViewAppBrowser.closeApp(Unknown Source)
at com.util.helpers.TestBase.tearDown(Unknown Source)

Will post back when I get -Dsikuli.Debug=3 working and see what kind of error messages appear.

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

This message comes from using Sikuli RC3 stuff.

Can it be, that you have some mix of RC3 and SikuliX 1.0.1 on your machine?

If you want to use version 1.0.1+ you have to take care, that nowhere in environment are pointers to the RC3 stuff.

Revision history for this message
J (jill-freeman) said :
#10

Hi RaiMan,

I don't think that I had any RC3 stuff on my machine, but my coworker figured out that we needed to use JRE instead of JDK and now it works. Thank you for all your help!

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

Interesting - though fine that it works.

I use only JDK's on all of my machines/systems and that works without problems.