Question

I'm calling a sikuli function, inside Sikuli IDE, but I get this error "NameError: global name 'openApp' is not defined"...

If I try to do openApp('calc') in a new Sikuli blank file, it works, but if I use in another .sikuli file like:

def sample():
    import myLib
    # my Lib is .py file that I've created and put it on sikuli-script.jar
    var = somevalue
    myLib.myFunction(something)
    openApp('calc')

I get the error with "openApp" and other sikuli funcions like "Key" (ex: Key.ENTER) too...

Hope I had explained that well

Was it helpful?

Solution

By default, Sikuli will insert a from sikuli import * into all main files. This error tends to occur when you import sikuli modules. If you are importing modules, you will need to add the import manually. See the documentation for more advice.

OTHER TIPS

If your tests are in the same folder basically you can do,

import testName
reload(testName)
from testName import *

This will import your test and execute it's content.

testName should be name of the file without .sikuli extension

I ran into a similar problem was solved by putting from sikuli import * at the first line of any file you are importing. I hope this helps!
I only mentioned this, because with the imported files, I had the greatest overall success with this one, and it became habit to make this the first line.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top