javajmetersikuli-x

Why does Sikulix code not working in JMeter


I have below Sikuli code in the JMeter which is not working.

import org.sikuli.script.Pattern;
import org.sikuli.script.Screen;
import org.sikuli.script.FindFailed;
import org.sikuli.script.KeyModifier;
import org.sikuli.script.Match;


Screen screen = new Screen();
Pattern VNCviewer = new Pattern ("C:\\scripts\\patterns\\vnc\\vncviewer.png");
screen.wait(VNCviewer,3);

I tried in both Beanshell sampler and JSR223 sampler and in both cases not working. Here is the error Im getting.

JSR223 sampler

Response code: 500

Response message: javax.script.ScriptException: javax.script.ScriptException: FindFailed: C:\scripts\patterns\vnc\vncviewer.png: (32x31) in R[0,0 1920x1080]@S(0) Line 2226, in file Region.java

Beanshell sampler

Response code: 500

Response message: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: ``import org.sikuli.script.Pattern; import org.sikuli.script.Screen; import org.si . . . '' : Method Invocation screen.wait

This code is working fine in another laptop and JMeter version same (5.0). I tried with different java version also. The file path is correct only and the png file exists.


Solution

  • The error means that the Sikuli isn't able to find the element matching your vncviewer.png image on the screen.

    Double check that the content of the vncviewer.png is present on the screen. It might also be the case you took the screenshot on a different machine having different screen resolution hence finding fails.

    You can try the following:

    1. Re-capturing the screenshot on the machine you're running JMeter and replacing the vncviewer.png with the "fresh" image from particular that machine

    2. Call Pattern.similar() function to allow more flexibility so Sikuli would look for "similar" image, not for "exact" image

    3. Enable debug logging for Sikuli by adding the following system property to JMeter command line:

      jmeter -Dsikuli.Debug=0 -t /path/to/your/testplan.jmx