Trying to get sikuli java-scripts running on Ubuntu through jenkins-maven

Asked by VJ

Few questions pertaining to this:

   - Do we need to prepare the linux/ubuntu environment for sikuli to work
  - Do we need to install sikuli software on Ubuntu or just using sikulixapi in our code is good enough ?
  -Jenkins is not able to find the sikuli-core and sikuli-api jars in the maven repository when executing the maven goal.. any changes we need to do on jenkins side
  - If we just put sikuli 1.1.2 dependency in the maven-pom file is good enough or do we need to download any other jars and include them in the buidlpath or classpath ?

Are there any related articles to read up on for this.. any pointer, any help if someone can throw some light ?
Anyone else faced similar issues like this...

Thank you...

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
VJ (gvvijayram) said :
#1

I tried to use the following below in the pom.xml,

                <dependency>
       <groupId>com.sikulix</groupId>
       <artifactId>sikulixapi</artifactId>
       <version>1.1.2</version>
  </dependency>
  <dependency>
   <groupId>org.sikuli</groupId>
   <artifactId>sikuli-api</artifactId>
   <version>1.2.0</version>
  </dependency>

Getting this error:
Failed to execute goal on project sel-sikuli-java-testng: Could not resolve dependencies for project sel-sikuli-java-testng:sel-sikuli-java-testng:jar:0.0.1-SNAPSHOT: Could not find artifact com.github.vidstige:jadb:jar:-v1.0-g94ebf38-23 in central (https://repo.maven.apache.org/maven2) -> [Help 1]

Need some help ..

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

       <groupId>com.sikulix</groupId>
       <artifactId>sikulixapi</artifactId>
       <version>1.1.2</version>
no longer supported. use 1.1.4-SNAPSHOT from OSSRH

   <groupId>org.sikuli</groupId>
   <artifactId>sikuli-api</artifactId>
   <version>1.2.0</version>
is another project (not SikuliX) and should not mixed up

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

Thank you Raiman;

Question: Can we run sikuli tests against headless browsers, we are running tests against headless browsers on docker containers and the code is failing.. wondering if it is possible, if not is there any alternative way to execute on headless browsers..

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

Generally SikuliX does not work in a real headless environment.

A possible solution (which I use on TravisCI for testing) is to run a fake screen using xvfb.

Revision history for this message
VJ (gvvijayram) said :
#6

Thank you Raiman for the pointer; is it possible to fake screen on Ubuntu ? and are there any steps on how to do it..

Thank you so much..

Revision history for this message
VJ (gvvijayram) said :
#7

I figured that we are using XVNC session to communicate with the browser on the jenkins-slave..

When I execute my scripts, Screen object initialization failed...

my Code Snippet below:

import org.sikuli.script.Screen;
public class Login extends Base {

    public Screen screen;
    public Login() {
          System.out.println("==== Login Before Flag...");
          screen = new Screen(); <--- Failing here, error stack-trace below
          System.out.println("==== Login After Flag..");
    }
Before flag is getting printed but after-flag is not getting printed... below is the error

java.lang.ExceptionInInitializerError: null
 at org.sikuli.script.RunTime.init(RunTime.java:693)
 at org.sikuli.script.RunTime.get(RunTime.java:291)
 at org.sikuli.script.RunTime.get(RunTime.java:126)
 at org.sikuli.script.RunTime.get(RunTime.java:316)
 at org.sikuli.script.Region.<clinit>(Region.java:31)
 at main.java.apps.login.Login.<init>(Login.java:17)
 at test.java.tests.login.TestLoginHelper.createLoginObject(TestLoginHelper.java:21)
 at test.java.tests.login.TestLogin.setup(TestLogin.java:17)

Any pointer will be helpful.......

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

does not look like the latest 1.1.4

Sorry, but I do not support older versions any more about such special situations.

Revision history for this message
VJ (gvvijayram) said :
#9

Defined this repository in settings.xml below:
       <repository>
        <id>sonatype-ossrh</id>
        <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
     </repository>

Defined sikulixapi dependency in pom.xml:

               <dependency>
   <groupId>com.sikulix</groupId>
   <artifactId>sikulixapi</artifactId>
   <version>1.1.4-SNAPSHOT</version>
  </dependency>

I am getting artifact not found error upon executing maven goal on jenkins:

Failed to execute goal on project sel-sikuli-java-testng: Could not resolve dependencies for project sel-sikuli-java-testng:sel-sikuli-java-testng:jar:0.0.1-SNAPSHOT: Could not find artifact com.sikulix:sikulixapi:jar:1.1.4-SNAPSHOT in internal-repository (http://engci-maven-master.cisco.com/artifactory/apic-em-repo)

I read somewhere else on a different post that 1.1.4 is slated for release in April.. is it okay to use it now ?

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

repo setting and dep info are correct

I do not know your environment, but apparently, the OSSRH repo is not accessed.

--- is it okay to use it now ?
Currently and surely for the next 4 weeks there will be new builds and hence snapshots nearly every day.
It is up to you, how you want to handle that.

If you want to stick with 1.1.2, I cannot help you as mentioned.

Revision history for this message
VJ (gvvijayram) said :
#11

Thank you so much Raiman... sorry I may have asked before but just confirming again..

On our docker container, we are creating headless display of the browser to open the page; and All our selenium based UI tests are working using that approach...

Do sikuli tests also work using that approach ?

Thank you...

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

--- headless display of the browser
IMHO (but I do not have that much experience): this is a Selenium specific feature, that can only be used by the respective Selenium features. It does not produce a system wide fake-X11 display like xvfb is doing it.

see my comment #5

Revision history for this message
VJ (gvvijayram) said :
#13

Fixed our Jenkins job and finally got 1.1.4 jar in the class path, below is the class path:

[DEBUG] test(compact) classpath: test-classes classes junit-3.8.1.jar testng-6.14.3.jar jcommander-1.72.jar bsh-2.0b6.jar selenium-java-3.141.59.jar selenium-api-3.141.59.jar selenium-chrome-driver-3.141.59.jar selenium-edge-driver-3.141.59.jar selenium-firefox-driver-3.141.59.jar selenium-ie-driver-3.141.59.jar selenium-opera-driver-3.141.59.jar selenium-remote-driver-3.141.59.jar selenium-safari-driver-3.141.59.jar selenium-support-3.141.59.jar byte-buddy-1.8.15.jar commons-exec-1.3.jar guava-25.0-jre.jar jsr305-1.3.9.jar checker-compat-qual-2.0.0.jar error_prone_annotations-2.1.3.jar j2objc-annotations-1.1.jar animal-sniffer-annotations-1.14.jar okhttp-3.11.0.jar okio-1.14.0.jar selenium-server-3.141.59.jar jcip-annotations-1.0.jar jetty-repacked-9.4.12.v20180830.jar javax.servlet-api-3.1.0.jar snakeyaml-1.19.jar json-simple-1.1.1.jar org.apache.commons.io-2.4.jar commons-io-2.4.jar sikulixapi-1.1.4-SNAPSHOT.jar surefire-testng-utils-2.16.jar surefire-grouper-2.16.jar

but still I am getting Initialization error while creating Pattern object below are the details:

Code:
import org.sikuli.script.Pattern;
public static final Pattern image = new Pattern(pathToImagesfolder + "loginimage.png").similar(0.1f);

Error:
FAILURE!
java.lang.ExceptionInInitializerError: null
 at org.sikuli.script.RunTime.libsExport(RunTime.java:880)
 at org.sikuli.script.RunTime.libsLoad(RunTime.java:783)
 at org.sikuli.script.RunTime.loadLibrary(RunTime.java:987)
 at org.sikuli.script.Finder2.<clinit>(Finder2.java:35)
 at org.sikuli.script.Pattern.<init>(Pattern.java:123)
 at main.java.apps.login.LoginPage.<clinit>(LoginPage.java:22)
 at main.java.apps.login.Login.enter_credentials(Login.java:35)
 at test.java.tests.login.TestLogin.test_login_with_valid_credentials(TestLogin.java:31)

Results :

Failed tests:
  TestLogin.test_login_with_valid_credentials:31 » ExceptionInInitializer

Unsure why ? even after the jar present in the classpath still it is failing...

Revision history for this message
VJ (gvvijayram) said :
#14

installed xvfb plugin on my slave; 1.1.4-SNAPSHOT jar is getting picked up; but still I am getting this above initialization error...

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

run with -Dsikuli.Debug=3 on the java command to get more debug info from SikuliX.

The problem is related to the exporting of native libs.
On Linux this is only the bundled libJXGrabKey.so.
The target folder is ~/.Sikulix/SikulixLibs

This folder must be writable in the Jenkins run environment.

Revision history for this message
VJ (gvvijayram) said :
#16

Thank you so much for the pointer, this is what I tried:

I’ve included the flag in my java-command and also ensured target folder is present on the slave and with proper writable permissions..

My environment: Ubuntu based docker-container-slave

My java command:
java -Dmaven.repo.local=/home/sdnbld/jenkins/workspace/APIC_QA/test/.m2 -Dsikuli.Debug=3 -cp /home/sdnbld/jenkins/maven33-agent.jar:/home/sdnbld/jenkins/tools/hudson.tasks.Maven_MavenInstallation/M3/boot/plexus-classworlds-2.5.2.jar:/home/sdnbld/jenkins/tools/hudson.tasks.Maven_MavenInstallation/M3/conf/logging jenkins.maven3.agent.Maven33Main /home/sdnbld/jenkins/tools/hudson.tasks.Maven_MavenInstallation/M3 /home/sdnbld/jenkins/remoting.jar /home/sdnbld/jenkins/maven33-interceptor.jar

Issue persists....

Few questions, Pardon my ignorance:

- The target folder will be automatically created or do we need to create one and give writable permissions for it on the slave ?

- Do we need to deploy Sikuli software on the Jenkins-slave...

- Just like Selinium-RC, can we execute sikuli-scripts on a remote-client or remote-slave?

Thank you so much...

Revision history for this message
VJ (gvvijayram) said :
#17

"On Linux this is only the bundled libJXGrabKey.so"
  -- do we need to install this library on linux and export that library in the Jenkins-shell

any other native libs I need to export ?

Revision history for this message
VJ (gvvijayram) said :
#18

Also why I am getting this library export issue with 1.1.4-SNAPSHOT jar; with 1.1.0 jar I didn't hit into this issue;
is this a bug in 1.1.4 with linux environment [failure to initialize Pattern object because library export issue]

Can you help with this problem?

Provide an answer of your own, or ask VJ for more information if necessary.

To post a message you must log in.