在Yosemite上如何使用Sikuli

      还是由于手贱,升级到yosemite(OS X 10.10), 在安装Sikuli 的IDE工具的时候发现不能使用。我使用Sikuli的IDE工具主要是为了写自动化case。

      case的最后一步需要判断播放器是可以播放流的,以前是测试人员使用手工测试的方式,人工判断流可以正常播放。为了方便我们使用编程的方式,我们在流里面加入了一个类似于台标的东西。通过Sikuli的API,去查找找个图标就可以判断,播放器不是黑屏,是可以正常播放流的(马赛克暂时不予考虑)。那么现在的问题是如何让Sikuli跑起来,首先是下载Sikuli-IDE的安装包Sikuli-X-1.0rc3 (r905)-osx-10.6.dmg, 虽然论坛里面也说过现在还不支持10.10。安装了之后发现压根不能启动,其实我也不是像用IDE工具,主要是想在jython调用Sikuli的API和截图。进入到安装目录/Applications/Sikuli-IDE.app/Contents/Resources/Java, 找到sikuli-script.jar的包,

使用命令:

java -jar sikuli-script.jar -i

 启动,报错:

    

java.io.IOException: Unable to find library META-INF/lib/libVisionProxy.dylib on classpath
	at com.wapmx.nativeutils.jniloader.DefaultJniExtractor.extractResource(DefaultJniExtractor.java:127)
	at com.wapmx.nativeutils.jniloader.DefaultJniExtractor.extractJni(DefaultJniExtractor.java:110)
	at com.wapmx.nativeutils.jniloader.NativeLoader.loadLibrary(NativeLoader.java:43)
	at org.sikuli.script.Finder.(Finder.java:33)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:270)
	at org.python.core.Py.loadAndInitClass(Py.java:895)
	at org.python.core.Py.findClassInternal(Py.java:830)
	at org.python.core.Py.findClassEx(Py.java:881)
	at org.python.core.packagecache.SysPackageManager.findClass(SysPackageManager.java:133)
	at org.python.core.packagecache.PackageManager.findClass(PackageManager.java:28)
	at org.python.core.packagecache.SysPackageManager.findClass(SysPackageManager.java:122)
	at org.python.core.PyJavaPackage.__findattr_ex__(PyJavaPackage.java:137)
	at org.python.core.PyObject.__findattr__(PyObject.java:863)
	at org.python.core.imp.import_name(imp.java:849)
	at org.python.core.imp.importName(imp.java:884)
	at org.python.core.ImportFunction.__call__(__builtin__.java:1220)
	at org.python.core.PyObject.__call__(PyObject.java:357)
	at org.python.core.__builtin__.__import__(__builtin__.java:1173)
	at org.python.core.imp.importFromAs(imp.java:978)
	at org.python.core.imp.importFrom(imp.java:954)
	at sikuli.Sikuli$py.f$0(/Applications/Sikuli-IDE.app/Contents/Resources/Java/sikuli-script.jar/Lib/sikuli/Sikuli.py:211)
	at sikuli.Sikuli$py.call_function(/Applications/Sikuli-IDE.app/Contents/Resources/Java/sikuli-script.jar/Lib/sikuli/Sikuli.py)
	at org.python.core.PyTableCode.call(PyTableCode.java:165)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.imp.createFromCode(imp.java:386)
	at org.python.core.util.importer.importer_load_module(importer.java:109)
	at org.python.modules.zipimport.zipimporter.zipimporter_load_module(zipimporter.java:161)
	at org.python.modules.zipimport.zipimporter$zipimporter_load_module_exposer.__call__(Unknown Source)
	at org.python.core.PyBuiltinMethodNarrow.__call__(PyBuiltinMethodNarrow.java:47)
	at org.python.core.imp.loadFromLoader(imp.java:513)
	at org.python.core.imp.find_module(imp.java:467)
	at org.python.core.PyModule.impAttr(PyModule.java:100)
	at org.python.core.imp.import_next(imp.java:715)
	at org.python.core.imp.import_name(imp.java:824)
	at org.python.core.imp.importName(imp.java:884)
	at org.python.core.ImportFunction.__call__(__builtin__.java:1220)
	at org.python.core.PyObject.__call__(PyObject.java:357)
	at org.python.core.__builtin__.__import__(__builtin__.java:1173)
	at org.python.core.imp.importAll(imp.java:998)
	at sikuli$py.f$0(/Applications/Sikuli-IDE.app/Contents/Resources/Java/sikuli-script.jar/Lib/sikuli/__init__.py:3)
	at sikuli$py.call_function(/Applications/Sikuli-IDE.app/Contents/Resources/Java/sikuli-script.jar/Lib/sikuli/__init__.py)
	at org.python.core.PyTableCode.call(PyTableCode.java:165)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.imp.createFromCode(imp.java:386)
	at org.python.core.util.importer.importer_load_module(importer.java:109)
	at org.python.modules.zipimport.zipimporter.zipimporter_load_module(zipimporter.java:161)
	at org.python.modules.zipimport.zipimporter$zipimporter_load_module_exposer.__call__(Unknown Source)
	at org.python.core.PyBuiltinMethodNarrow.__call__(PyBuiltinMethodNarrow.java:47)
	at org.python.core.imp.loadFromLoader(imp.java:513)
	at org.python.core.imp.find_module(imp.java:467)
	at org.python.core.imp.import_next(imp.java:713)
	at org.python.core.imp.import_name(imp.java:824)
	at org.python.core.imp.importName(imp.java:884)
	at org.python.core.ImportFunction.__call__(__builtin__.java:1220)
	at org.python.core.PyObject.__call__(PyObject.java:357)
	at org.python.core.__builtin__.__import__(__builtin__.java:1173)
	at org.python.core.imp.importAll(imp.java:998)
	at org.python.pycode._pyx0.f$0(:1)
	at org.python.pycode._pyx0.call_function()
	at org.python.core.PyTableCode.call(PyTableCode.java:165)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.Py.runCode(Py.java:1261)
	at org.python.core.Py.exec(Py.java:1305)
	at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:206)
	at org.python.util.jython.run(jython.java:280)
	at org.python.util.jython.main(jython.java:129)
	at org.sikuli.script.SikuliScript.startInteractiveMode(SikuliScript.java:93)
	at org.sikuli.script.SikuliScript.main(SikuliScript.java:106)
[info] Mac OS X utilities loaded.
[info] VDictProxy loaded.

 

   虽然报错,但是貌似是可以工作了, 执行一下截图:

   

img = capture()

 

   结果立即报错, 退出。

   Google了半天也没有什么结论,不过有人说试一下jdk1.6说不定可以。设置了一下环境变量:

   

export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
java -version
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode)

  

   再启动一下:

   

java -jar sikuli-script.jar -i
[info] Sikuli vision engine loaded.
[info] Mac OS X utilities loaded.
[info] VDictProxy loaded.
>>> img = capture()
>>>

 

竟然好了, 可以截图,也可以调用Sikuli的API了。

你可能感兴趣的:(在Yosemite上如何使用Sikuli)