Problems running unit tests from Win7 command line

Asked by J. Simmons

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):
 self.notepad.open()
 wait("UntitledNote.png", 20000)

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

def test_textarea_add_del_by_key(self):
 type("hello world")
 assert exists("helloworld.png")
 type("a",KEY_CTRL)
 type("\n")
 assert not exists("helloworld.png")

def test_textarea_add_del_by_key_clipboard(self):
 type("hello world")
 # fill clipboard for assert
 type("a",KEY_CTRL)
 type("c",KEY_CTRL)
 assert Env.getClipboard() == "hello world"
 type("\n")
 # fill clipboard for assert
 type("a",KEY_CTRL)
 type("c",KEY_CTRL)
 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] App.open 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?

Thanks!

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

any non ascii characters or blanks in this path?

c:\users\username\Desktop\

Revision history for this message
J. Simmons (jedibfa) said :
#2

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

Revision history for this message
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>)
test(None)

Revision history for this message
J. Simmons (jedibfa) said :
#4

Gotcha. Do I need to create the bug report?

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

bug is reported

Revision history for this message
J. Simmons (jedibfa) said :
#6

Thanks RaiMan, that solved my question.

Revision history for this message
Tsung-Hsiang Chang (vgod) said :
#7

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

Revision history for this message
J. Simmons (jedibfa) said :
#8

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

Revision history for this message
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.

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

@ surfdork

this is wrong:

setBundlePath = ("C:\\SikuliImages")

correct:
setBundlePath("C:\\SikuliImages")

Revision history for this message
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.

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

requested by a user, because private data was used accidentally

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

should not show up

Revision history for this message
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.