Problems running unit tests from Win7 command line

Asked by J. Simmons on 2011-10-04

I am running Sikuli X 1.0rc3 on Win7 Professional x64. My goal is to use the unit test features of Sikuli to write some automated tests. I have built several demo unit test scripts (testing notepad and an in house app) which run fine in the Sikuli IDE, but do not run correctly from the command line.

For example, here is a notepad test file I have written (this is the python code, obviously it has the pretty pictures in the IDE):

notepad = App("notepad.exe")

def setUp(self):
 wait("UntitledNote.png", 20000)

def tearDown(self):
 waitVanish("UntitledNote-1.png", 20000)

def test_textarea_add_del_by_key(self):
 type("hello world")
 assert exists("helloworld.png")
 assert not exists("helloworld.png")

def test_textarea_add_del_by_key_clipboard(self):
 type("hello world")
 # fill clipboard for assert
 assert Env.getClipboard() == "hello world"
 # fill clipboard for assert
 assert not Env.getClipboard() == "hello world"

When I run this from the IDE (toggle Unit Tests from the View menu, then click the Unit Tests run button), everything runs fine and I get 2/2 tests run to completion. However, when I run it from the command line, the tests fail with "[error] UntitledNote.png looks like a file, but can't be found on the disk. Assume it's text." Full output below:

C:\Users\username\Desktop>"%SIKULI_HOME%\sikuli-ide.bat" -t c:\users\username\Desktop\notepad_tests.sikuli
[info] Sikuli vision engine loaded.
[info] Windows utilities loaded.
[info] VDictProxy loaded.
.[log] notepad.exe(7868)
[error] UntitledNote.png looks like a file, but can't be found on the disk. Assume it's text.
[info] Text Recognizer inited.
[error] UntitledNote.png looks like a file, but can't be found on the disk. Assume it's text.
[error] UntitledNote.png looks like a file, but can't be found on the disk. Assume it's text.

So, it looks to me like this is some sort of pathing issue. I have tried adding the path to the .sikuli directory to the image path as the first line of the script based on another Q&A, but that did not work. Are there other steps I should try to troubleshoot this?


Question information

English Edit question
SikuliX Edit question
No assignee Edit question
Last query:
Last reply:
RaiMan (raimund-hocke) said : #1

any non ascii characters or blanks in this path?


J. Simmons (jedibfa) said : #2

No, the username just ascii characters, and there are no blanks in it.

RaiMan (raimund-hocke) said : #3

confirmed: this is a bug.

tested on same configuration:

--- run with -t from command line gives the above error
def test(self):
    print find(<some-image>)

--- run with -r from command line - this works
def test(self):
    print find(<some-image>)

J. Simmons (jedibfa) said : #4

Gotcha. Do I need to create the bug report?

RaiMan (raimund-hocke) said : #5

bug is reported

J. Simmons (jedibfa) said : #6

Thanks RaiMan, that solved my question.

Tsung-Hsiang Chang (vgod) said : #7

Try to use addImagePath to get around this bug for now.

J. Simmons (jedibfa) said : #8

I tried using addImagePath, but either I was doing it wrong or it did not help.

RaiMan (raimund-hocke) said : #9

Confirmed: the only thing, that helps is using absolute path's for the images.

even getBundlePath() returns some rubbish when used on command line in unit test.

RaiMan (raimund-hocke) said : #11

@ surfdork

this is wrong:

setBundlePath = ("C:\\SikuliImages")


RaiMan (raimund-hocke) said : #13

Don't bother about wasting my time: It is my decision how I use my time - so if I answer, it is not wasted ;-)

--- xlrd usage:
in the package folder of xlrd inside the folder xlrd there is a doc and an examples folder, that should give sufficient help and insights.

RaiMan (raimund-hocke) said : #14

requested by a user, because private data was used accidentally

RaiMan (raimund-hocke) said : #15

should not show up

RaiMan (raimund-hocke) said : #16

back to life

Can you help with this problem?

Provide an answer of your own, or ask J. Simmons for more information if necessary.

To post a message you must log in.