X-1.0rc3: Windows: Unittest from command line with -t: image files not found --- workaround

Bug #867636 reported by RaiMan on 2011-10-04
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Sikuli
Undecided
RaiMan

Bug Description

***** workaround

use Python's unitttest feature directly and run the scripts normally in IDE and with option -r from command line.

see faq 1804

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

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?

RaiMan (raimund-hocke) wrote :

some more information in the linked question

Changed in sikuli:
status: New → Confirmed
David Burns (sci-burns) wrote :

I'm also seeing this issue, would love to have it fixed - working a POC, trying to decide if Sikuli would work to replace a commercial product...

RaiMan (raimund-hocke) wrote :

@ David

since this is a problem, when running test scripts from command line, the test feature of the IDE is not really needed.

So I recommend to use Python's unittest feature directly, by just adding a few lines of code (see faq 1804).

summary: X-1.0rc3: Windows: Unittest from command line with -t: image files not
- found
+ found --- workaround
description: updated
surfdork (surfdork) wrote :

@ Raimund

I have the same issue when running Sikuli form the NetBeans IDE

I tried copying the images to the Sikuli folder containing the copy of the sikuli-script.jar copies to a different location ( due to known path issues with windows)
Still occurs.
Is there any type of workaround. I'm not clear about the automatic paths generated by Sikuli, I'd like to disable that feature since I'm working with an image bank I need to keep separate.
What I'd like is to have good ole setBundlePath working as it used to however any workaround would be greatly appreciated.

RaiMan (raimund-hocke) wrote :

@ surfdork

--- running Sikuli form the NetBeans IDE
Using Python/Jython environment or Java?

--- I'd like is to have good ole setBundlePath
on the Python level, setBundlePath() should work as expected.
on Java level you can use the imagePath feature.

RaiMan (raimund-hocke) wrote :

@ surfdork

you have to subscribe to a bug when adding comments and expecting an answer ;-)

RaiMan (raimund-hocke) wrote :

no longer supported

Changed in sikuli:
status: Confirmed → Won't Fix
assignee: nobody → RaiMan (raimund-hocke)
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers