← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #226007]: how do i for create one switch test in sikuli?

 

Question #226007 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/226007

    Status: Open => Answered

RaiMan proposed the following answer:
There is no "one-command" solution for running other scripts from a main
script.

You have to organize/script this on your own, based on the existing
Python/Jython features:

1. execfile()
no changes needed in your script, but a bit more complicated to implement, because you have to tell Sikuli where to locate the used images.

2. import
the executed scripts must be changed to importable modules (the code to run has to be in functions ( def runMe(): ). But the usage is much easier, since it automatically gives access to the related images.
(see http://doc.sikuli.org/globals.html#importing-other-sikuli-scripts-reuse-code-and-images)

--- a general solution for 1.

- supposing all scripts are in the same folder

# main script

import os
dir = os.path.dirname(getBundlePath()) # our working dir with the scripts

# run some scripts in sequence
for script in ("LancarItem", "Login", "FecharConta"):
    scriptsik = script + ".sikuli"
    scriptpy = os.path.join(scriptsik, script + ".py")
    setBundlePath(os.path.join(dir, scriptsik) # folder for images
    execfile(os.path.join(dir, scriptpy)) # runs the code

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.