RaiMan / SikuliX-2014

SikuliX version 1.1.2 (until February 2018)
http://sikulix.com
806 stars 235 forks source link

Screen Class not found of SikuliX. #294

Open princiverma1803 opened 6 years ago

princiverma1803 commented 6 years ago

Hi, I am using maven in Sikuli Project. I have used following dependency and repository in Pom.xml -

com.sikulix sikulixapi 1.1.0 com.sikulix com.sikulix https://oss.sonatype.org/content/groups/public default true always

Its working for me when I execute this code after creating exe of my code, actually we provide exe only to client but the problem is for Sikuli, exe is not working on other systems.

It executes only till image path but Screen class does not find. Screen screen = new Screen();

There is no exception in the logs as well.

Kindly suggest some solutions.

Thanks & Regards, Princi Verma

RaiMan commented 6 years ago

please be more specific:

princiverma1803 commented 6 years ago

Hi RaiMan,

But the problem is exe does not work for other system.

And we are not getting the reason. Please help.

Thanks!

princiverma1803 commented 6 years ago

public StepReturn clickSikuli(String image){ Log.info("Image name is ---> "+image); String imgPath = sikuliImagePath+"/"+image; Log.info("Image path is ----> "+imgPath); File imgFile = new File(imgPath); if(!imgFile.exists()){ String testCase[] = report.getTestName().split(" "); String testImgDir = testCase[0].replace(".xlsm", "").trim();; Log.info("TestCase Name ----> "+testImgDir);
Log.info("Test case image directory name ---> "+testImgDir); imgPath = testLibraryPath+"/"+testImgDir+"/"+image; Log.info("image path inside testcase folder ---> "+imgPath); imgFile = new File(imgPath);
if(!imgFile.exists()){ Log.info("Image does not exist at any Path (Configuration/ORPicture or TestLibrary/test folder), please add the image first."); return new StepReturn(StepReturnEnum.FAIL); } } Log.info("Before Sikuli Screen ------>>>>>>");
Screen screen = new Screen(); Log.info("Screen class name ------->>> "+screen.getClass()); Log.info("After Sikuli..1" ); Log.info("Image File is ---> "+imgFile);
org.sikuli.script.Pattern imgPattern = new org.sikuli.script.Pattern(""+imgFile);
Log.info("Screen Object is created ----> "+screen); try { screen.wait(imgPattern.similar((float)0.60),2).click(); } catch (FindFailed e) {
Log.error("Exception in finding the image ---> "+e); return new StepReturn(StepReturnEnum.FAIL, "exception in finding the following image '" + image); }
return new StepReturn(StepReturnEnum.PASS); }

princiverma1803 commented 6 years ago

I have written the above code.

RaiMan commented 6 years ago

ok, understood.

My guess for the reasons: Before packing the .exe, I suppose you are testing from inside Eclipse. If yes, then at SikuliX init, to the SikuliX eco-system some stuff (e.g. the native libraries) is exported from the sikulix.jar. If you then run the .exe on that system, it will see the already existing eco-system and not try to export again. So it has everything at hand and works.

Then trying to run this exe on a system never touched by normal SikuliX before, does not work, because the needed stuff cannot be exported from the sikulixapi.jar embedded inside the .exe. This was my experience with launch4j 2 years ago and because I did not find an immediate solution, I stopped playing around with launch4j.

You might test that on your system, where the .exe works: Remove the SikuliX stuff before running the .exe and it should fail. (running some un-wrapped SikuliX features will restore the stuff from the .jar)

If you know, how to get something out of the .exe, I will try to help you to get on the road.

princiverma1803 commented 6 years ago

Yes, RaiMan,

Before creating the exe, I execute the code from eclipse, its working and taking the required jar from maven repository - '.m2\repository\com\sikulix\sikulixapi\1.1.0'. After creating the exe it works for me and if someone else try to create exe from his system, by creating the jar from updated code in eclipse then, exe works for him as well, but for any new system, who only has the exe, does not work.

The problem is, we cannot share the code with everyone, we only provide the exe to execute the test case and it does not work for clickSikuli action.

So, Is the problem with Launch4j?

How the exe can work for others? What could be the possible solutions?

Thanks and Regards, Princi Verma

princiverma1803 commented 6 years ago

I tried to execute the test case with .exe after removing the sikulixapi from maven repository and test case run without any problem.

RaiMan commented 6 years ago

With removing "SikuliX stuff" I meant the folder in your application store according to http://sikulix-2014.readthedocs.io/en/latest/basicinfo.html#sikulix-system-specifics

If you delete at least the folder

SikulixLibs_TIMESTAMP (the place for the exported native libraries)

then I guess the .exe will not work (reason see above).

A quick solution can only be, to have the sikulixapi.jar on the system running the .exe somewhere and take care, that she place is on the java class path at runtime. In this case, sikulixapi.jar need not be in the .exe.

Might be, that launch4j has some support for that.

princiverma1803 commented 6 years ago

Hi RaiMan,

Yes got your point. Now this is working for others also.

Thanks a lot !

Regards, Princi Verma

RaiMan commented 6 years ago

Please give me a short description of your concrete solution. Thanks.

princiverma1803 commented 6 years ago

Actually, I just copied my auto generated 'Sikulix' folder (inside '\AppData\Roaming' folder), to the system I wanted to run the exe and it worked. Thanks !

RaiMan commented 6 years ago

ok, thanks.

Hoped, you had a solution based on some special launch4J setup :-(

... I have it now on the list again.

last question: what did you do to secure your code in the .exe? In my opinion it is not safe, if you did nothing:

princiverma1803 commented 6 years ago

Hi RaiMan,

We don't have done any implementation to secure the code in .exe. Kindly suggest how we can secure our code.

Thanks & Regards, Princi Verma

RaiMan commented 6 years ago

Kindly suggest how we can secure our code.

I have no idea currently, sorry. I only wanted you to be aware of that.

Usually people ask for the .exe variant with SikuliX scripts or programs, because they think their code would be safe against copyright violation. But principally it is not safer, as when you publish your product as a simple runnable jar file.

princiverma1803 commented 6 years ago

Ohh, Ok.... No Problem.

Thanks !