← Back to team overview

sikuli-driver team mailing list archive

[Question #303256]: How to use relative path in Sikuli to load another python script

 

New question #303256 on Sikuli:
https://answers.launchpad.net/sikuli/+question/303256

Hi all,

In my testing environment, I want to define a main sikuli script that calls and runs all sub-test cases defined by different sikuli scripts. And each sikuli script of each test case will refer to a common test setup file that exists in the folder of the main sikuli script

Here is the folder structure:
                 |-Main_Test.sikuli
                 |      |-Main_Test.py
                 |      |-set_config.py
                 |-TestCase1.sikuli
                 |      |-TestCase1.py
                 |............
                 
Here is the code in TestCase1.py script to load the setup_config.py file:

  configFilePath = "..\\Main_Test"                           
  if not configFilePath in sys.path:
           sys.path.append(configFilePath)
  import setup_config
  reload(setup_config)
  .............. read out configs and do the test ..................

When I run TestCase1 in Sikuli IDE, It reports setup_config is not found.
If I use the absolute path, then it works fine (I dont want to use the absolute path here because we want to be able to run the test on different PC by just copying the whole environment and execute the main script without any modification to sub sikuli scripts)

Can you please help to use relative path to load a python module in sikuli script.

Thanks,
HuyK

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.