1

我正在尝试单击图像,并且我还需要检查 NUM_LOCK 是打开还是关闭,如果它打开,我需要切换是否关闭,为此我使用下面的 sikuli 脚本并使用 seleniumDriver 代码的 executescript 命令运行它如下但它给了我错误

"Exception Occured ::org.openqa.selenium.WebDriverException: No signature of 
method: static org.sikuli.script.Env.isLockOn() is applicable for argument 
types: (java.lang.String) values: [?]
Possible solutions: isLockOn(char)"

下面的代码

String typeFromDate = "import org.sikuli.script.Screen;\n"+
                "import org.sikuli.script.Key;\n"+
                "import org.sikuli.script.KeyModifier;\n"+
                "import org.sikuli.script.Env;\n"+
                "Screen screen = new Screen();\n"+
                "screen.doubleClick(\""+fromDateImgPath.trim()+"\");\n"+
                "Thread.sleep(2000);\n"+
                "if(Env.isLockOn(Key.NUM_LOCK))screen.type(Key.NUM_LOCK);"+
                "screen.type(Key.HOME); \n"+
                "Thread.sleep(5000);\n"+
                "screen.keyDown(Key.SHIFT) \n"+
                "screen.type(Key.END) \n"+
                "screen.keyUp(Key.SHIFT) \n"+
                "Thread.sleep(5000);\n"+
                "screen.type(\""+fromDate+"\"); \n"+
                "Thread.sleep(2000);\n"+
                "return null;\n"; 

 returnfrDt = (String) aDriver.executeScript(typeFromDate, new String[] 
{"GROOVY"});
4

1 回答 1

0

使用 Jython,这非常简单:

if Env.isLockOn(Key.NUM_LOCK):
    print('NUM_LOCK is ON')
于 2019-04-17T16:24:27.243 回答