Unable to run Sikuli Java project from Maven test command

Asked by lybersord

The automation runs perfectly fine from Eclipse IDE, but when the automation is invoked from Maven, the App.open and App.close all works but anything related to clicking image does not. The output says it is clicking but nothing happens on the screen. Is there anything that I am missing.?

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

What Sikuli version?

Revision history for this message
lybersord (rijoy-r) said :
#2

Sikuli Version 1.0.1

Revision history for this message
RaiMan (raimund-hocke) said :
#3

add this JVM runtime option
-Dsikuli.Debug=3

to hopefully see some enlightening debug output.

Revision history for this message
lybersord (rijoy-r) said :
#4

I enabled the option and this the output for the first click event:

[debug] Screen.capture: java.awt.Rectangle[x=283,y=104,width=625,height=738]
[debug] RobotDesktop: captureScreen: on 0 using java.awt.Rectangle[x=283,y=104,width=625,height=738]
[debug] ResourceLoaderBasic: loadLib: VisionProxy
[debug] ResourceLoaderBasic: loadLib: Found: VisionProxy
[debug] ResourceLoaderBasic: loadLib: Now loaded: VisionProxy
[debug] ImageLocator: found resources/images/win2k12/CtrlAltDelScreen.png in C:\myDepot\automation\Agents\LAC\GUI
[debug] Screen.capture: java.awt.Rectangle[x=283,y=104,width=625,height=738]
[debug] RobotDesktop: captureScreen: on 0 using java.awt.Rectangle[x=283,y=104,width=625,height=738]
[debug] Screen.capture: java.awt.Rectangle[x=283,y=104,width=625,height=738]
[debug] RobotDesktop: captureScreen: on 0 using java.awt.Rectangle[x=283,y=104,width=625,height=738]
[debug] Screen.capture: java.awt.Rectangle[x=283,y=104,width=625,height=738]
[debug] RobotDesktop: captureScreen: on 0 using java.awt.Rectangle[x=283,y=104,width=625,height=738]
[debug] Screen.capture: java.awt.Rectangle[x=283,y=104,width=625,height=738]
[debug] RobotDesktop: captureScreen: on 0 using java.awt.Rectangle[x=283,y=104,width=625,height=738]
[debug] Screen.capture: java.awt.Rectangle[x=283,y=104,width=625,height=738]
[debug] RobotDesktop: captureScreen: on 0 using java.awt.Rectangle[x=283,y=104,width=625,height=738]
[debug] Screen.capture: java.awt.Rectangle[x=283,y=104,width=625,height=738]
[debug] RobotDesktop: captureScreen: on 0 using java.awt.Rectangle[x=283,y=104,width=625,height=738]
[debug] Screen.capture: java.awt.Rectangle[x=283,y=104,width=625,height=738]
[debug] RobotDesktop: captureScreen: on 0 using java.awt.Rectangle[x=283,y=104,width=625,height=738]
[debug] Screen.capture: java.awt.Rectangle[x=283,y=104,width=625,height=738]
[debug] RobotDesktop: captureScreen: on 0 using java.awt.Rectangle[x=283,y=104,width=625,height=738]

Still unable to figure out what's wrong. Hope you can help me.
Thanks.

Revision history for this message
RaiMan (raimund-hocke) said :
#5

It seems that the image is not found (CtrlAltDelScreen.png)

Could you paste some code snippet?

Revision history for this message
lybersord (rijoy-r) said :
#6

if (window.exists(imageOf("CtrlAltDelScreen")) != null){
     System.out.println("CtrlAltDel screen exists...");
            window.click(imageOf("sendCtrlAltDelBtn"));
}

where "window" is

if(App.focus("TightVNC")) == null){
 System.out.println("Opening the VNC viewer");
 App.open(prop.vncViewer + " -host=" + prop.testMachine);
 window = App.focusedWindow();
}

and imageOf gives the location of image file

Revision history for this message
RaiMan (raimund-hocke) said :
#7

*** System.out.println("CtrlAltDel screen exists...");
… is not processed I guess (cannot see the message in the output in comment #4)

if it is a timing problem: increase waiting time

if (window.exists(imageOf("CtrlAltDelScreen"), 10) != null){
     System.out.println("CtrlAltDel screen exists...");
            window.click(imageOf("sendCtrlAltDelBtn"));
}

and add a message to be clear:

if (window.exists(imageOf("CtrlAltDelScreen")) != null){
     System.out.println("CtrlAltDel screen exists...");
            window.click(imageOf("sendCtrlAltDelBtn"));
} else {
         System.out.println("CtrlAltDel screen did not appear...");
}

BTW: you could use

Debug.user("some message %s", variable) (internally String.format() is used)

to get log messages nice and easy even with time stamps.

these are the relevant settings: Settings. …

  public static boolean UserLogs = true;
  public static String UserLogPrefix = "user";
  public static boolean UserLogTime = true;

Revision history for this message
lybersord (rijoy-r) said :
#8

Thanks for the pointers about logging, really appreciate it.

But the problem persists...

When run from Eclipse :

Looking for image : C:\myDepot\automation\Agents\LAC\GUI\resources\images\win2k12\CtrlAltDelScreen.png
[debug] Screen.capture: java.awt.Rectangle[x=0,y=0,width=1280,height=970]
[debug] RobotDesktop: captureScreen: on 0 using java.awt.Rectangle[x=0,y=0,width=1280,height=970]
[debug] ResourceLoaderBasic: loadLib: VisionProxy
[debug] ResourceLoaderBasic: loadLib: Found: VisionProxy
[debug] ResourceLoaderBasic: loadLib: Now loaded: VisionProxy
CtrlAltDel screen exists...
Looking for image : C:\myDepot\automation\Agents\LAC\GUI\resources\images\win2k12\sendCtrlAltDelBtn.png
[debug] waiting for C:\myDepot\automation\Agents\LAC\GUI\resources\images\win2k12\sendCtrlAltDelBtn.png to appear
[debug] Screen.capture: java.awt.Rectangle[x=0,y=0,width=1280,height=970]
[debug] RobotDesktop: captureScreen: on 0 using java.awt.Rectangle[x=0,y=0,width=1280,height=970]
[debug] C:\myDepot\automation\Agents\LAC\GUI\resources\images\win2k12\sendCtrlAltDelBtn.png has appeared.
[log] CLICK on L(294,106)@S(0)[0,0 1280x1024]

The same from maven:
Looking for image : C:\myDepot\automation\Agents\LAC\GUI\resources\images\win2k12\CtrlAltDelScreen.png
[debug] Screen.capture: java.awt.Rectangle[x=283,y=104,width=625,height=738]
[debug] RobotDesktop: captureScreen: on 0 using java.awt.Rectangle[x=283,y=104,width=625,height=738]
[debug] ResourceLoaderBasic: loadLib: VisionProxy
[debug] ResourceLoaderBasic: loadLib: Found: VisionProxy
[debug] ResourceLoaderBasic: loadLib: Now loaded: VisionProxy
[debug] Screen.capture: java.awt.Rectangle[x=283,y=104,width=625,height=738]
[debug] RobotDesktop: captureScreen: on 0 using java.awt.Rectangle[x=283,y=104,width=625,height=738]
.
.
.
CtrlAltDel screen does not exist

Revision history for this message
lybersord (rijoy-r) said :
#9

By the way, I have added only "sikuli-java" as a dependency jar in the project, do I need any other sikuli related jars.?

Revision history for this message
Best RaiMan (raimund-hocke) said :
#10

@comment #9: NO

@comment #9
the image CtrlAltDelScreen.png is not visible for Sikuli in the Maven case.

in your code you restrict the search to the focused window, with is in case
eclipse:
Screen.capture: java.awt.Rectangle[x=0,y=0,width=1280,height=970]
(seems to be maximized window)

Maven:
Screen.capture: java.awt.Rectangle[x=283,y=104,width=625,height=738]
which is much smaller

So it might be, that you get the wrong window, which gives you the wrong region, that does not contain the image ;-)

Revision history for this message
RaiMan (raimund-hocke) said :
#11

sorry the second entry should read of course

@comment #8
the image CtrlAltDelScreen.png is not visible for Sikuli in the Maven case.
….

Revision history for this message
lybersord (rijoy-r) said :
#12

Thanks RaiMan, that solved my question.

Revision history for this message
lybersord (rijoy-r) said :
#13

The issue was right in front of my eyes, being printed multiple times, but I didn't see it and wouldn't have either, until you pointed it out. Thanks Raiman, really appreciate your help.

And ya.. Sikuli rocks ;-)

Revision history for this message
RaiMan (raimund-hocke) said :
#14

thanks for kind feedback.