1

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"});
Nitin Rathod
  • 159
  • 2
  • 15
  • I don't understand, all your code is a String. How do you expect it to do anything? – Eugene S Dec 06 '18 at 10:39
  • I am working on WorkFusion Tool which is an automation tool in which we can write sikuli scripts as strings and then we can execute it using this command aDriver.executeScript(typeFromDate, new String[] {"GROOVY"}); – Nitin Rathod Dec 06 '18 at 11:25
  • That sounds like extremely complicated way to do that but whatever. In your case, the issues is the type you provide into `isLockOn` method. It complains that you give it a String when it expects something else. – Eugene S Dec 06 '18 at 11:37

1 Answers1

0

With Jython, it is pretty simple:

if Env.isLockOn(Key.NUM_LOCK):
    print('NUM_LOCK is ON')
Assi.NET
  • 432
  • 4
  • 7