javaseleniumgroovysikuli-scriptworkfusion

Clicking on Image using Sikuli and Env.isLockOn(Key.NUM_LOCK) not working


I am trying to Click on image and also i need to check if NUM_LOCK is on or off if it is on i need to switch if off and for that i am using below sikuli script and running it using executescript command of seleniumDriver code is as below but its is giving me error as

"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)"

Below Code

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"});

Solution

  • With Jython, it is pretty simple:

    if Env.isLockOn(Key.NUM_LOCK):
        print('NUM_LOCK is ON')