rainmanwy / robotframework-SikuliLibrary

Sikuli Robot Framework Library provide keywords for Robot Framework to test UI through Sikuli.
Apache License 2.0
144 stars 61 forks source link

SikuliLibrary not working on Ubuntu-20.04 (Docker) #184

Open Sunil-onecom opened 1 year ago

Sunil-onecom commented 1 year ago

Hi, We are trying to run SikuliLibrary on the docker container but we are getting this error

WARN ] Test get_keyword_names failed! Connecting remote server at http://127.0.0.1:39207/ failed: <Fault 0: 'Failed to invoke method get_keyword_names in class org.robotframework.remoteserver.servlet.ServerMethods: java.lang.RuntimeException'> [ WARN ] Test get_keyword_names failed! Connecting remote server at http://127.0.0.1:39207/ failed: <Fault 0: 'Failed to invoke method get_keyword_names in class org.robotframework.remoteserver.servlet.ServerMethods: java.lang.RuntimeException'> [ ERROR ] Error in file '/webmail/Page_Objects/Login_PO.robot' on line 5: Initializing library 'SikuliLibrary' with no arguments failed: Failed to get_keyword_names! Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/SikuliLibrary/sikuli.py", line 54, in init self.start_sikuli_process(port) File "/usr/local/lib/python3.8/dist-packages/SikuliLibrary/sikuli.py", line 93, in start_sikuli_process self.remote = self._connect_remote_library() File "/usr/local/lib/python3.8/dist-packages/SikuliLibrary/sikuli.py", line 208, in _connect_remote_library self._test_get_keyword_names(remote) File "/usr/local/lib/python3.8/dist-packages/SikuliLibrary/sikuli.py", line 225, in _test_get_keyword_names raise RuntimeError('Failed to get_keyword_names!') RuntimeError: Failed to get_keyword_names! Test Cases.Login :: This file would contain Test_Cases related to login fo

rainmanwy commented 1 year ago

hi, how about the jdk version? this url is serviced by java process. and how about the console output of the java process?

Sunil-onecom commented 1 year ago

Jdk version is java-11-openjdk, When I'm expecting the same command on my system which is ubuntu:20.04 robot --console verbose -x xunit.xml --outputdir reports -i 'Login' Test_Cases Test cases are running without any error but when execting same command on ubuntu:20.04 container I'm getting this error. This is my Dockerfile

`FROM ubuntu:20.04

ENV DEBIAN_FRONTEND noninteractive ENV LANG=en_US.UTF-8

RUN apt-get update \ && apt-get install -y wmctrl xdotool libcanberra-gtk0 libcanberra-gtk-module libopencv4.2-java \ libcanberra-gtk0 libcanberra-gtk-module libopencv4.2-java tesseract-ocr libtesseract-dev libtesseract4 \ build-essential libssl-dev libffi-dev python-dev \ python3-pip python-dev gcc phantomjs firefox libopencv-dev tesseract-ocr \ xvfb zip unzip wget ntpdate openjdk-11-jdk \ libnss3-dev libxss1 libappindicator3-1 libindicator7 gconf-service libgconf-2-4 libpango1.0-0 xdg-utils fonts-liberation \ && rm -rf /var/lib/apt/lists/*

Setup JAVA_HOME, this is useful for docker commandline

ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64/

RUN export JAVA_HOME RUN ln -s /usr/lib/jni/libopencv_java420.so /usr/lib/libopencv_java.so COPY requirements.txt .

RUN pip install -r requirements.txt

RUN wget -q https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz \ && tar xvzf geckodriver-.tar.gz \ && rm geckodriver-.tar.gz \ && mv geckodriver /usr/local/bin \ && chmod a+x /usr/local/bin/geckodriver

install chrome and chromedriver in one run command to clear build caches for new versions (both version need to match)

RUN wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \ && dpkg -i google-chrome.deb \ && rm google-chrome.deb \ && CHROME_MAJOR_VERSION=$(google-chrome --version | sed 's/. ([0-9]+)../\1/') \ && CHROME_DRIVER_FILE=$(wget -q -O - https://chromedriver.storage.googleapis.com/ | sed "s,.($CHROME_MAJOR_VERSION.[0-9.]/chromedriver_linux64.zip).*,\1,g") \ && wget -q "https://chromedriver.storage.googleapis.com/$CHROME_DRIVER_FILE" \ && unzip chromedriver_linux64.zip \ && rm chromedriver_linux64.zip \ && mv chromedriver /usr/local/bin \ && chmod +x /usr/local/bin/chromedriver

WORKDIR / RUN mkdir /Testcases COPY . /Testcases/ `

rainmanwy commented 1 year ago

@Sunil-onecom , so your local Ubuntu has been installed desktop, and you execute robot command from desktop, right? Do the docker image include desktop?

if yes, maybe should set "DISPLAY" environment variable, before execute test cases. https://sikulix-2014.readthedocs.io/en/latest/basicinfo.html#sikulix-can-be-used-for-visual-testing

and also could check https://sikulix-2014.readthedocs.io/en/latest/newslinux.html

Sunil-onecom commented 1 year ago

Right, my local Ubuntu has been installed desktop. Docker image includes no desktop. We can't open desktop in containers