如何解决Sikulix 1.1.1中的PyException错误?

时间:2017-11-22 04:16:30

标签: sikuli jython-2.5 sikuli-script sikuli-ide

我在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:\Users\Administrator\Desktop\UI_testing\Setup\sikulix.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)

1 个答案:

答案 0 :(得分:0)

assert语句正在测试一个评估为TrueFalse的布尔表达式。但是,如果找不到模式或模式中的exists(),则Sikuli Match函数会返回None个对象。您需要相应地重写代码。

另外,我不会像这样使用highlight(),因为它不清楚是什么突出显示。