← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #243363]: import scripts does not work always. I have tried so many times but succeeded only twice or thrice.

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
stuff to be used from imported scripts should be packed into functions
and/or classes to be useful, since imported code on level 0 is only run
at first import and on reload (see http://doc.sikuli.org/globals.html
#importing-other-sikuli-scripts-reuse-code-and-images).

Since you decided to do more complex things than just some find()s and
click()s, you have to learn some Python basics.

this is how it should be:

# Login.sikuli
from sikuli import *
def doLogin():
    openApp("C:\\Program Files\\Mozilla Firefox\\firefox.exe")
    wait(3)
    url = "www.staging.shipsticks.com"
    type(url+Key.ENTER)
    wait(10)
    if exists("1391517318147.png"):
        click("1391517318147.png")
    else:
        click("1391518980878.png")
    click("1391517318147.png")
    #<rest of the code>

# main script
import Login
Login.doLogin()
exists("1391519760686.png")
click("1391519760686.png")
wait(3)
<rest of the code>

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