Unable to run script due to import issues

Asked by Nidhi Bhushan on 2018-08-30

I am new to sikuli but managed to write some scripts (that would run well in sikuli IDE). Then I took the next step and created a detailed framework to test my desktop based application. But I am facing errors when I try to run my test script.
FYI, I am using sikuli with python along with HTMLTestRunner for reporting.
Below is directory structure for my folder SikuliFramework_PRE2019

BaselineImages (contains all my baseline images to be used in test cases)
Output (HTMLTestRunner creates html output file in this directory)
TestData (contains excel which would determine which test I want to run)
TestDriver (folder having below scripts)
       HTMLTestRunner.py (this is RaiMan's test reporting script available on net)
       TestDriver.py (my driver script)
TestScripts
       Effects.sikuli
                       Effects.py (my test script)

Inside my driver script TestDriver.py, I am trying to add Effects class in test suite by writing below line:
self.suite = unittest.TestSuite()
self.suite.addTest(Effects('Effects'))

But it shows error on running:
ERROR: test_main (__main__.Test_HTMLTestRunner)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\Users\nbhushan\Desktop\SikuliFramework_PRE2019\TestDriver\TestDriver.py", line 43, in test_main
    self.suite.addTest(Effects('Effects'))
NameError: global name 'Effects' is not defined

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

I understand that my directory structure is the problem here but I want to keep it this way. It appears that there is some import error. Please suggest solution to this problem.

PS. I am also unable to do 'from sikuli import *'
On doing pip install sikuli on command line, it says 'Exception: Unable to determine JRE_HOME'

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
Nidhi Bhushan
Solved:
2018-08-31
Last query:
2018-08-31
Last reply:
2018-08-30
RaiMan (raimund-hocke) said : #1

Are you aware of the fact, that SikuliX uses Jython (Java based) and not Python (C-based)?

Nidhi Bhushan (nidhibhushan) said : #2

@RaiMan
Thanks for reverting. Yes, I am aware. What am I doing wrong here? I ran my driver script from command prompt, still same error. Please elaborate.

Nidhi Bhushan (nidhibhushan) said : #3

Additionally, please suggest the right way to execute my test scripts (keeping in mind my directory structure and I want to control test execution from excel)

Nidhi Bhushan (nidhibhushan) said : #4

Well, now it hit me. I should instead have a driver.sikuli file and execute this sikuli script from command line. Problem solved.
@RaiMan: Thanks!!