Using common function defs in other scripts
I've viewed quite a few articles around this subject, the primary one being https:/
However, from the primary article, I have as always tried a simple example, and created the following files and directories :
+-- lib.sikuli (contains lib.py and button.png)
def pressButton():
click(
---
+-- script.sikuli (contains script.py)
execfile(
pressButton()
---
However, upon trying to execute script.py, I am getting the following exception :
edu.
I assume this is because script.py is invoking the pressButton command, and looking for button.png in the script.sikuli directory, and not the lib.sikuli directory. So is there a simple way of adding this directory into the "search path" or whatever concept Python / Sikuli uses to find the images ?
As an aside, I did try some of the more involved "include" function examples, but I am trying to write unit test scripts at the moment, and was having trouble with these concepts. I am hoping, once I have got this working, I can simply put the execfile command into a setUp function, and then these library functions (along with requried images) can be available in all the test methods. Not sure if any of this might change any advice offered.
Many thanks for your assistance,
Ben
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- SikuliX Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- RaiMan
- Solved:
- Last query:
- Last reply: