>我的sikuli脚本中遇到以下错误
+++ running this Java
java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) Client VM (build 23.21-b01, mixed mode, sharing)
+++ trying to run SikuliX
+++ using: -Xms64M -Xmx512M -Dfile.encoding=UTF-8 -Dsikuli.FromCommandLine -jar
C:UsersAdministratorDesktopUI_testingSetupsikulix.jar
[info] HotkeyManager: add Capture Hotkey: CTRL+SHIFT 2 (50, 3)
[info] HotkeyManager: add Abort Hotkey: ALT+SHIFT C (67, 9)
[error] IDE: Remembered window not valid. Going to primary screen
Exception: **org.python.core.PyException thrown from the UncaughtExceptionHandler
in thread "Thread-13"**
检查并发现代码卡在我使用图像作为字典元素的行上
for i in menubar:
exists(menubar[i]).highlight(3)
menubar
是一个python字典,其中包含以名称作为键存储的图像。
PS : 代码
from sikuli import *
menubar={"file":"menubar_file.png","edit":"menubar_edit.png","view":"menubar_view.png","administration":"menubar_administration.png","tools":"menubar_tools.png","help":"menubar_help.png"}
for i in menubar:
assert exists(menubar[i]).highlight(2)
assert
语句正在测试计算结果为True
或False
的布尔表达式。但是,Sikuliexists()
函数返回一个Match
对象,如果未找到模式或模式中的None
。您需要相应地重写代码。
另外,我不会像这样使用highlight()
,因为不清楚它突出显示了什么。