script not working when executed via command line with option -t

Asked by j

--- the problem

Running tests from command line using Sikuli-IDE.bat with option -t lead to some odd behavior, if the .sikuli folder starts with the letter a, x and some others. using c or m as first letter seems to be safe.

see comments #10 +

------------------------------------------------------------------------------------------

I use Win32, JDK 1.6_22, and Sikuli X 1.0rc2.

I worte a testcase that looks something like this:

def setUp(self):
    pass

def tearDown(self):
    pass

def testSomething(self):
    app = App.open("app.exe")
    wait("appgui.png")
    assert(True)

I can execute this test successfully within the sikuli-ide, but when I try to do the same test via command line, I get a FindFail Exception at the "wait()" command.

I have added \Sikuli x\ to my Path, so I opened cmd, changed to the directory with the .sikuli file with the test, and then executed

sikuli-ide.bat -t test.sikuli

Is there any known bug concerning this, or am I just doing something wrong?

Thanks for your replies

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

The only explanation, that I can see, is that it takes more than 3 seconds until the image "app.gui" gets visible for Sikuli.

try: wait("appgui.png", 10)

Revision history for this message
j (j-the-k) said :
#2

hi, thanks for your reply.
Unfortunately this was not the sollution.
Here is my exact Script and the Stacktrace, maybe you can tell me what I did wrong :X

Script:
def setUp(self):
 pass

def tearDown(self):
 pass

def testTest(self):
 calcApp = App.open("calc.exe")

 img = "IRcchncrBear.png"

 wait(img,10)
 click(img)

 assert(True)
 calcApp.close()

C:\Tests>sikuli-ide.bat -t test1.sikuli
[info] Sikuli vision engine loaded.
[info] Windows utilities loaded.
[info] VDictProxy loaded.
.[log] App.open calc.exe(5804)
[info] Text Recognizer inited.
E
Time: 10,266
There was 1 error:
1) testTest(org.python.proxies.__main__$test1$4)FindFailed: can not find IRcchnc
rBear.png
  Line 29, in file <string>

        at org.sikuli.script.Region.handleFindFailed(Region.java:349)
        at org.sikuli.script.Region.wait(Region.java:420)
        at org.python.proxies.sikuli.Region$Region$1.super__wait(Unknown Source)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java
:175)
        at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java
:190)
        at org.python.core.PyObject.__call__(PyObject.java:432)
        at org.python.core.PyObject.__call__(PyObject.java:436)
        at sikuli.Region$py.wait$7(C:\Programme\SikuliX\sikuli-script.jar\Lib\si
kuli\Region.py:95)
        at sikuli.Region$py.call_function(C:\Programme\SikuliX\sikuli-script.jar
\Lib\sikuli\Region.py)
        at org.python.core.PyTableCode.call(PyTableCode.java:165)
        at org.python.core.PyBaseCode.call(PyBaseCode.java:297)
        at org.python.core.PyBaseCode.call(PyBaseCode.java:191)
        at org.python.core.PyFunction.__call__(PyFunction.java:385)
        at org.python.core.PyMethod.__call__(PyMethod.java:215)
        at org.python.core.PyMethod.instancemethod___call__(PyMethod.java:221)
        at org.python.core.PyMethod.__call__(PyMethod.java:206)
        at org.python.core.PyObject.__call__(PyObject.java:414)
        at org.python.core.PyObject.__call__(PyObject.java:418)
        at org.python.pycode._pyx0.testTest$6(<string>:29)
        at org.python.pycode._pyx0.call_function(<string>)
        at org.python.core.PyTableCode.call(PyTableCode.java:165)
        at org.python.core.PyBaseCode.call(PyBaseCode.java:297)
        at org.python.core.PyBaseCode.call(PyBaseCode.java:191)
        at org.python.core.PyFunction.__call__(PyFunction.java:385)
        at org.python.core.PyMethod.__call__(PyMethod.java:215)
        at org.python.core.PyMethod.instancemethod___call__(PyMethod.java:221)
        at org.python.core.PyMethod.__call__(PyMethod.java:206)
        at org.python.core.PyObject.__call__(PyObject.java:381)
        at org.python.core.PyObject.__call__(PyObject.java:385)
        at org.python.pycode._pyx0.runTest$3(<string>:12)
        at org.python.pycode._pyx0.call_function(<string>)
        at org.python.core.PyTableCode.call(PyTableCode.java:165)
        at org.python.core.PyBaseCode.call(PyBaseCode.java:297)
        at org.python.core.PyBaseCode.call(PyBaseCode.java:191)
        at org.python.core.PyFunction.__call__(PyFunction.java:385)
        at org.python.core.PyMethod.__call__(PyMethod.java:215)
        at org.python.core.PyMethod.instancemethod___call__(PyMethod.java:221)
        at org.python.core.PyMethod.__call__(PyMethod.java:206)
        at org.python.core.PyObject.__call__(PyObject.java:367)
        at org.python.core.PyObject._jcallexc(PyObject.java:3500)
        at org.python.proxies.__main__$test1$4.runTest(Unknown Source)
        at org.sikuli.ide.sikuli_test.TextUnitTestRunner.testSikuli(TextUnitTest
Runner.java:33)
        at org.sikuli.ide.SikuliIDE.runUnitTest(SikuliIDE.java:842)
        at org.sikuli.ide.SikuliIDE.main(SikuliIDE.java:870)

FAILURES!!!
Tests run: 1, Failures: 0, Errors: 1

Revision history for this message
j (j-the-k) said :
#3

Could it be, that sikuli cannot find - of what reason ever - the imagefile? How can I test if sikuli could load the image-file?

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

I made some tests, since it is not easy, to guess without more information and insight, wether the FindFailed exception is because the image cannot be found on the screen, or if the file itself cannot be found (will be more informative with rc3).

Nevertheless, It seems, you are working on a german Windows.

From https://files.me.com/rhocke/zpsan6
you can download my test script (a zipped .sikuli) with calc.exe (tested on german Windows), that might give you some insight, how you could use the test feature of Sikuli in a more complex approach.

As a bonus, this contains a "hack", that allows to run one or more of the test cases directly in the IDE, without disturbing the run in the unit test environment (in IDE or command line). So you can test your test cases in the IDE until they are error free.

Come back if you have any questions or contact me directly.

Revision history for this message
j (j-the-k) said :
#5

Okay, so your script works fine on my PC.
Problem is: As soon as I try to use another script, none of the images is found.
Even if I copy your script (ctrl+c on calctest.sikuli, ctrl+v, rename file and scriptfile in it), it will not work!
If I copy the script into a new opened tab in the IDE, save this one as a new script and copy the images from your script into the folder of the new one, it will not work either.

I feel like I'm missing something big here.. I just cannot see what

Revision history for this message
j (j-the-k) said :
#6

Okay, so I'm in a really confuising situation now..
I have RaiMans testscript that is working.
I saved it to another location (sikuli IDE -> save as) -> works fine
I saved this to another location (sikuli IDE -> save as) without making ANY changes(!!) -> Find Failed Exceltion
I saved this to another location (sikuli IDE -> save as) again without ANY changes -> "[error] null" when trying to run it

what is wrong here?

Revision history for this message
j (j-the-k) said :
#7

This has something to do with filenames..

I jsut figured out, that if I save the script to new location, it works fine most of the times, as long as I don't name it "buttonTest.sikuli".. With that Testname, I always get a FindFailed Exception..

Does Sikuli have some kind of cache that maybe contaiins deprecated information?

examples (all of the files are exact duplicates of each other):

buttonTest.sikuli -> Find Failed
muttonTest.sikuli (first letter m instead of b) -> Works
xyzBlaTest.sikuli -> [error]null
yyzBlaTest.sikuli (first letter y instead of x) -> Works

So at the moment it is dependant on my filenames if the script works

I don't know what causes this, but I would consider this behaviour a bug

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

try to use filenames all lowercase letters.

Update Java to the newest version, if nothing else hinders you.

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

One more thing:
there are problems with filenames containing blanks and other special characters. so store your scripts in a folder whose absolute path does not contain these (a problem with Jython 2.5.1, contained in Sikuli currently)

your path might contain j_the_k ???

Revision history for this message
j (j-the-k) said :
#10

sorry for commenting so much here, but I'm really confused about this..
I just tried something:
I took RaiMans Script (calcTest.sikuli) -> works, and saved this script to different names.
This is the console log of sikuli ide:

[debug] save to bundle: C:/Tests/a.sikuli/
[debug] save to bundle: C:/Tests/b.sikuli/
[debug] save to bundle: C:/Tests/c.sikuli/
[debug] save to bundle: C:/Tests/d.sikuli/
[debug] save to bundle: C:/Tests/e.sikuli/
[debug] save to bundle: C:/Tests/f.sikuli/
[debug] save to bundle: C:/Tests/x.sikuli/
[debug] save to bundle: C:/Tests/m.sikuli/

Then I run all of the scripts with sikuli-ide.bat -t <filename.sikuli>

The Results (reproducable):
a.sikuli -> Find Failed Exception
b.sikuli -> Find Failed Exception
c. sikuli to e.sikuli -> Working fine
f.sikuli -> [error]:null
x.sikuli -> [error]:null
m.sikuli -> Working fine

Can you or anyone else confirm this behaviour or is this defenitely my Sikuli-installation/Computer messed up somehow?

All this Tests are stored in C:\Tests\
Sikuli is installed in C:\Programme\SikuliX\
both paths do not contain whitespaces and no special characters except \ and :

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

I herewith confirm the behavior on Win7-32 with the newest build of rc3:

Running tests from command line using Sikuli-IDE.bat with option -t lead to the above mentioned odd behavior, if the .sikuli folder starts with the letter a, x and some others. using c or m as first letter seems to be safe.

This is definitely a bug.

Do you have the time and motivation to post it?

Revision history for this message
j (j-the-k) said :
#12

I have postet a bug now (hope you haven't yet)

https://bugs.launchpad.net/sikuli/+bug/826769

Thanks for your confirmation and your patient replies =)