Trying out Sikuli in Java with sikulixapi 1.1.0, but it doesn't find my image files.
screen.click("images/Terminal.png");
Maven (shade) put my src/main/resources/images into the JAR's toplevel "images" directory as expected. But running the uberjar doesn't find the image.
~/hello $ java -cp target/hello.jar hello.TestSikuli
[error] Image: could not be loaded: file://Users.../hello/images/Terminal.png
It's looking in the current directory (happens to be the project directory), not in the JAR. I printed out the imagePath in the program, and it's an empty array.
How do I get it (perhaps with imagePath.add?) to search the invoked JAR? I had imagined it would look there by default.
Another thing I tried:
URL u = this.getClass().getClassLoader().getResource("images/Terminal.png");
Region r = screen.find(u);
But that blows up; if I pass a URL as shown here, I get "invalid parameter"; if I pass the .toString, I get:
FindFailed: Region: doFind: Image not loadable:
jar:file:/Users/.../Sikulix/j/hello/target/hello-1.0-SNAPSHOT.jar!/images/Terminal.png
There doesn't seem to be a stream input interface in Sikluix, so maybe this just can't be done.
This worked:
ImagePath.add(TestSikuli.class.getCanonicalName() + "/images");
There may also be a workaround of loading the image into memory. https://answers.launchpad.net/sikuli/+question/232217
import this library
import org.sikuli.basics.ImageLocator;
and use this function to locate your image directory path
ImageLocator.setBundlePath("path to img directory");
and to execute your jar file run the following commands
cd "your directory"
java -jar hello.jar
Screen s1 = new Screen();
s.dragDrop("Drag elemtn location.png","Drag elemtn location.png");
You can give the element path location which you want to drag and same as drop.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.