robotframework-SikuliLibrary icon indicating copy to clipboard operation
robotframework-SikuliLibrary copied to clipboard

Failed to get_keyword_names!

Open nouhab opened this issue 3 years ago • 21 comments

hi Team, I try to run skuliLibrary framework under a docker file.
The scenarios is as follow: 1.Create a docker file

FROM node:14-alpine

RUN apk update \

  && apk add build-base python3

RUN mkdir /.npm \
  && chmod 777 /.npm

RUN apk add --update  py3-pip
RUN apk add openjdk11
# CHROME
RUN apk --no-cache upgrade && apk add --no-cache chromium chromium-chromedriver
RUN apk add libexif udev

# ROBOT + LIBRARIES
RUN pip3 install robotframework && pip3 install robotframework-selenium2library  && pip3 install robotframework-jsonlibrary && pip3 install robotframework-jsonlibrary &&  pip3 install robotframework-SikuliLibrary

RUN apk update && apk add bash

ENTRYPOINT ["/bin/terraform"]
  1. docker build to build the image
  2. docker run -it -d -P robotfram ==>-P option to forword all ports to the host machine which is a windows machine
  3. docker cp "C:\Users\nboujelben\Downloads\test" sleepy_goodall:/home==>copy the test folder from local to my container
  4. my test file named robot.test and it contains a simple example:
*** Settings ***
Documentation     Sikuli Library Demo
Library           Selenium2Library
Library           SikuliLibrary
Test Setup        Run Keywords      Start Sikuli Process    AND  Initialize all images
Test Teardown     Stop Remote Server



*** Keywords *** 
Initialize all images
    Add Image Path      ${CURDIR}\\img
Login to Browser with download preferences
    [Documentation]   This one is without specifying download location
    
    Open Browser  https://www.docdroid.net/   chrome    #options=add_argument("--no-sandbox");add_argument("--headless");add_argument("--disable-dev-shm-usage")
    Maximize Browser Window
    Click Element   id=select
    SikuliLibrary.Input Text      path.png    ${CURDIR}\\img\\signature.jpeg
    Press Special Key   ENTER
    
*** Test cases  ***
Sikuli tests
    Log ToConsole   ${CURDIR}
    Login to Browser with download preferences

6.docker exec -it 2305c31c6cd7 /bin/sh ==>i connect to my container 7.export DISPLAY=127.0.0.1:10.0 ==>create an env variable named DISPLAY 8. apk add opencv-dev apk add tesseract-ocr 8. run a test as folow robot test.robot 9. I get this erreur:

  /home/test # robot test.robot
==============================================================================
Test :: Sikuli Library Demo
==============================================================================
[ WARN ] Test get_keyword_names failed! Connecting remote server at http://127.0.0.1:55781/ 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:55781/ failed: <Fault 0: 'Failed to invoke method get_keyword_names in class org.robotframework.remoteserver.servlet.ServerMethods: java.lang.RuntimeException'>
Sikuli tests                                                          | FAIL |
Setup failed:
Failed to get_keyword_names!

Also teardown failed:
AttributeError: 'NoneType' object has no attribute 'run_keyword'
------------------------------------------------------------------------------
Test :: Sikuli Library Demo                                           | FAIL |
1 test, 0 passed, 1 failed
==============================================================================
Output:  /home/test/output.xml
Log:     /home/test/log.html
Report:  /home/test/report.html

nouhab avatar Aug 18 '22 19:08 nouhab

hi, @nouhab could you confirm the version installed in docker? And do not need call "Start Sikuli Process" in test setup. sikuli process will be started when library is initialized by RF.

In new version, get_keyword_names do not connect remote server by default. so the error should not be like this.

rainmanwy avatar Aug 19 '22 02:08 rainmanwy

hi, i have the last version installed in my docker file:

cat version.py
Created on 2015/12/10
Author: by [email protected]
VERSION = '2.0.3'

when i remove the Start Sikuli Process i get this error :

Sikuli tests                                                          | FAIL |
Setup failed:
AttributeError: 'NoneType' object has no attribute 'run_keyword'

nouhab avatar Aug 19 '22 08:08 nouhab

could you execute test.robot with command "robot -L trace test.robot", and attach log here. And i think there is log.html and several sikuli log files.

rainmanwy avatar Aug 19 '22 08:08 rainmanwy

Thanks for your response .

/home/test # robot -L trace test.robot
==============================================================================
Test :: Sikuli Library Demo
==============================================================================
Sikuli tests                                                          | FAIL |
Setup failed:
AttributeError: 'NoneType' object has no attribute 'run_keyword'

Also teardown failed:
AttributeError: 'NoneType' object has no attribute 'run_keyword'
------------------------------------------------------------------------------
Test :: Sikuli Library Demo                                           | FAIL |
1 test, 0 passed, 1 failed
==============================================================================
Output:  /home/test/output.xml
Log:     /home/test/log.html
Report:  /home/test/report.html

I get the log.html file which is attached here . log.txt

nouhab avatar Aug 19 '22 09:08 nouhab

could check start server manually. And check console output.

rainmanwy avatar Aug 19 '22 09:08 rainmanwy

i start the server manually by typing this command : nohup java -jar /usr/lib/python3.10/site-packages/SikuliLibrary/lib/SikuliLibrary.jar 8081 /home/test/img &

then i change my code to

*** Settings ***
Documentation     Sikuli Library Demo
Library           Selenium2Library
Library           SikuliLibrary  mode=NEW
Test Setup        Run Keywords



*** Keywords ***
#Initialize all images
#    Add Image Path      ${CURDIR}/img
Login to Browser with download preferences
    [Documentation]   This one is without specifying download location


    Open Browser  https://www.docdroid.net/   chrome  options=add_argument("--no-sandbox");add_argument("--headless");add_argument("--disable-dev-shm-usage")
    Maximize Browser Window
    Click Element   id=select
    SikuliLibrary.Input Text   /home/test/img/path.png  /home/test/img/signature.jpeg
    #SikuliLibrary.Click   openFile.png
    Press Special Key   ENTER
*** Test cases  ***
Sikuli tests
    Log ToConsole   ${CURDIR}
    Login to Browser with download preferences

Unfortunally i still get the error AttributeError: 'NoneType' object has no attribute 'run_keyword' log.txt

nouhab avatar Aug 19 '22 16:08 nouhab

@rainmanwy Any suggestion to resolve the problem please ?

nouhab avatar Aug 22 '22 07:08 nouhab

i mean the console output of java process. actually most sikuli related keywords are implemented by java

获取Outlook for Androidhttps://aka.ms/AAb9ysg


From: nouhab @.> Sent: Monday, August 22, 2022 3:53:30 PM To: rainmanwy/robotframework-SikuliLibrary @.> Cc: Rainmanwy @.>; Mention @.> Subject: Re: [rainmanwy/robotframework-SikuliLibrary] Failed to get_keyword_names! (Issue #177)

@rainmanwyhttps://github.com/rainmanwy Any suggestion to resolve the problem please ?

― Reply to this email directly, view it on GitHubhttps://github.com/rainmanwy/robotframework-SikuliLibrary/issues/177#issuecomment-1221984714, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABVMAE2JDWU42EBVT2IC2TLV2MWXVANCNFSM566GZUHA. You are receiving this because you were mentioned.Message ID: @.***>

rainmanwy avatar Aug 22 '22 13:08 rainmanwy

/home/test # cat nohup.out WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance. 13:40:24.435 [main] INFO org.eclipse.jetty.util.log - Logging initialized @524ms to org.robotframework.remoteserver.logging.Jetty2Log4J 13:40:24.492 [main] INFO org.eclipse.jetty.server.Server - jetty-9.4.31.v20200723; built: 2020-07-23T17:57:36.812Z; git: 450ba27947e13e66baa8cd1ce7e85a4461cacc1d; jvm 11.0.16+8-alpine-r0 13:40:24.548 [main] INFO org.eclipse.jetty.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@141e5bef{/,null,AVAILABLE} 13:40:24.567 [main] INFO org.eclipse.jetty.server.AbstractConnector - Started ServerConnector@2f01783a{HTTP/1.1, (http/1.1)}{0.0.0.0:8081} 13:40:24.568 [main] INFO org.eclipse.jetty.server.Server - Started @658ms

nouhab avatar Aug 22 '22 13:08 nouhab

RE @rainmanwy,

I try to build the sukiliLibrary under my docker file and i get the some error==>step mvn package

#18 97.91 [WARNING] Parameter tasks is deprecated, use target instead
#18 98.11 [INFO] Executing tasks
#18 98.11
#18 98.11 main:
#18 98.12      [echo] unzip package
#18 98.13     [unzip] Expanding: /robotframework-SikuliLibrary/target/SikuliLibrary.zip into /robotframework-SikuliLibrary/target/src
#18 99.57      [echo] generate keywords.py
#18 99.80      [exec] Free TCP port is: 35565
#18 99.80      [exec] Start sikuli java process on port 35565
#18 100.9      [exec] Sikuli java process is started
#18 106.0      [exec] Test get_keyword_names failed! Connecting remote server at http://127.0.0.1:35565/ failed: <Fault 0: 'Failed to invoke method get_keyword_names in class org.robotframework.remoteserver.servlet.ServerMethods: java.lang.RuntimeException'>
#18 107.0      [exec] Traceback (most recent call last):
#18 107.0      [exec]   File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
#18 107.0      [exec]     return _run_code(code, main_globals, None,
#18 107.0      [exec]   File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
#18 107.0      [exec]     exec(code, run_globals)
#18 107.0      [exec]   File "/robotframework-SikuliLibrary/target/src/SikuliLibrary/__init__.py", line 15, in <module>
#18 107.0      [exec]     main()
#18 107.0      [exec]   File "/robotframework-SikuliLibrary/target/src/SikuliLibrary/__init__.py", line 11, in main
#18 107.0      [exec]     lib = SikuliLibrary(mode='CREATE')
#18 107.0      [exec]   File "/robotframework-SikuliLibrary/target/src/SikuliLibrary/sikuli.py", line 61, in __init__
#18 107.0      [exec]     self._create_keywords_file()
#18 107.0      [exec]   File "/robotframework-SikuliLibrary/target/src/SikuliLibrary/sikuli.py", line 101, in _create_keywords_file
#18 107.0      [exec]     self.start_sikuli_process()
#18 107.0      [exec]   File "/robotframework-SikuliLibrary/target/src/SikuliLibrary/sikuli.py", line 93, in start_sikuli_process
#18 107.0      [exec]     self.remote = self._connect_remote_library()
#18 107.0      [exec]   File "/robotframework-SikuliLibrary/target/src/SikuliLibrary/sikuli.py", line 208, in _connect_remote_library
#18 107.0      [exec]     self._test_get_keyword_names(remote)
#18 107.0      [exec]   File "/robotframework-SikuliLibrary/target/src/SikuliLibrary/sikuli.py", line 225, in _test_get_keyword_names
#18 107.0      [exec]     raise RuntimeError('Failed to get_keyword_names!')
#18 107.0      [exec] RuntimeError: Failed to get_keyword_names!




My docker file is as follow:

FROM node:12-alpine

RUN apk update && apk add build-base python3

RUN mkdir /.npm \
  && chmod 777 /.npm

RUN apk add --update  py3-pip
RUN ln -s /usr/bin/python3 /usr/bin/python
RUN apk add openjdk11
# CHROME
RUN apk --no-cache upgrade && apk add --no-cache chromium chromium-chromedriver
RUN apk add libexif udev
#Sikulix
RUN apk add opencv-dev
RUN apk add tesseract-ocr

# ROBOT + LIBRARIES
RUN pip3 install robotframework && pip3 install robotframework-selenium2library  && pip3 install robotframework-jsonlibrary
RUN apk add maven \
  && apk add git
RUN git clone --quiet https://github.com/rainmanwy/robotframework-SikuliLibrary.git > nouha.txt
RUN export DISPLAY=127.0.0.1:10.0
RUN cd robotframework-SikuliLibrary \
 && mvn package
RUN python3 setup.py install
RUN apk update && apk add bash
#RUN chmod -R 777 /usr/lib/python3.9/site-packages/SikuliLibrary
#RUN cp target/SikuliLibrary.jar /usr/lib/python3.9/site-packages/SikuliLibrary/lib/SikuliLibrary.jar
RUN export DISPLAY=127.0.0.1:10.0



ENTRYPOINT ["/bin/sh"]




nouhab avatar Aug 23 '22 10:08 nouhab

/home/test # cat nohup.out WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance. 13:40:24.435 [main] INFO org.eclipse.jetty.util.log - Logging initialized @524ms to org.robotframework.remoteserver.logging.Jetty2Log4J 13:40:24.492 [main] INFO org.eclipse.jetty.server.Server - jetty-9.4.31.v20200723; built: 2020-07-23T17:57:36.812Z; git: 450ba27947e13e66baa8cd1ce7e85a4461cacc1d; jvm 11.0.16+8-alpine-r0 13:40:24.548 [main] INFO org.eclipse.jetty.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@141e5bef{/,null,AVAILABLE} 13:40:24.567 [main] INFO org.eclipse.jetty.server.AbstractConnector - Started ServerConnector@2f01783a{HTTP/1.1, (http/1.1)}{0.0.0.0:8081} 13:40:24.568 [main] INFO org.eclipse.jetty.server.Server - Started @658ms

@nouhab, from the log, java process is started successfully. image you may use "Remote" library to call sikuli keywords. and check the console output of java process.

#18 99.80 [exec] Free TCP port is: 35565 #18 99.80 [exec] Start sikuli java process on port 35565 #18 100.9 [exec] Sikuli java process is started #18 106.0 [exec] Test get_keyword_names failed! Connecting remote server at http://127.0.0.1:35565/ failed: <Fault 0: 'Failed to invoke method get_keyword_names in class org.robotframework.remoteserver.servlet.ServerMethods: java.lang.RuntimeException'> #18 107.0 [exec] Traceback (most recent call last):

at least from the log, sikuli process is started with port 35565. but failed to get keywords from url http://127.0.0.1:35565/. maybe there are some error logs from java process.

here is sikuli process output: image

and python test script In [1]: from robot.libraries.Remote import Remote

In [2]: r = Remote('http://127.0.0.1:10000/')

In [3]: r.get_keyword_names() Out[3]: ['setAlwaysResize', 'imageCount', 'returnMatchFromRegion', 'changeScreenId', 'captureRegion', 'doubleClickOnMatch',

rainmanwy avatar Aug 24 '22 02:08 rainmanwy

I am having the same issue when trying to build with maven. Has this issue been concluded?

erdemkucuk avatar Sep 09 '22 13:09 erdemkucuk

@erdemkucuk , thank you for the report. How about your OS version, JDK version. have you tried "start server manually" method, is there some errors in the console output?

rainmanwy avatar Sep 19 '22 07:09 rainmanwy

@rainmanwy, Hi I've tried this on Ubuntu 20.04 and tried both OpenJDK 11 and 17. Unfortunately teared down my setup and no longer able to access logs.

erdemkucuk avatar Sep 20 '22 10:09 erdemkucuk

Hello to all,

I met a similar issue in the past (to be confirmed it it may solve yours). I’m working on Almalinux 8. I installed the opencv rpm package thinking it would install all libraries. When I ran SikuliXide.jar, everything worked as expected, but when I ran my own Robot frameword code, i got the error message you raised. In my case it was due to the fact that the Almalinux package was not providing the libopencv_java.so : this library is present in the Sikulixide.jar but not in the SikuliLibrary.jar, hence the difference in term of behaviour.

As a workaround, i unzipped the sikulixide.jar and retrieved the libopencv_java430.so (adapt version if necessary), i added it to my Dockerfile (add also a link from libopencv_java.so to libopencv_java430.so). The proper way would be to recompile it but i had few time and just wanted to check it was solving the issue. You may also need to add the library to the CLASSPATH environment variable.

Hope it helps.

bloye avatar Oct 30 '22 06:10 bloye

@rainmanwy Hi I've also tried this on Ubuntu 20.04 docker image and facing the same error, So do you have an official docker image for Sikuli? [ 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 2[25](https://gitlab.one.com/qa-india/webmail/-/jobs/1410801#L25), 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

Sunil-onecom avatar Dec 07 '22 08:12 Sunil-onecom

I see the same problem. Windows 10, Python 3.10, JRE 1.8.0_351.

danieltegenfeldt avatar Dec 07 '22 10:12 danieltegenfeldt

[ WARN ] Test get_keyword_names failed! Connecting remote server at http://127.0.0.1:50865/ 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:50865/ failed: <Fault 0: 'Failed to invoke method get_keyword_names in class org.robotframework.remoteserver.servlet.ServerMethods: java.lang.RuntimeException'> [ ERROR ] Error in file 'c:\Testprojekt\test.robot' on line 2: Initializing library 'SikuliLibrary' with no arguments failed: Failed to get_keyword_names! Traceback (most recent call last): File "C:\Users\241208\AppData\Local\Programs\Python\Python310\lib\site-packages\SikuliLibrary\sikuli.py", line 54, in init self.start_sikuli_process(port) File "C:\Users\241208\AppData\Local\Programs\Python\Python310\lib\site-packages\SikuliLibrary\sikuli.py", line 93, in start_sikuli_process self.remote = self._connect_remote_library() File "C:\Users\241208\AppData\Local\Programs\Python\Python310\lib\site-packages\SikuliLibrary\sikuli.py", line 208, in _connect_remote_library self._test_get_keyword_names(remote) File "C:\Users\241208\AppData\Local\Programs\Python\Python310\lib\site-packages\SikuliLibrary\sikuli.py", line 225, in _test_get_keyword_names raise RuntimeError('Failed to get_keyword_names!') RuntimeError: Failed to get_keyword_names!

danieltegenfeldt avatar Dec 07 '22 10:12 danieltegenfeldt

I have the same problem (exactly same error messages). Running it locally not in Docker.

Windows 10, robotframework 7.0, python 3.12.3, java 1.8.0_381

superhans2 avatar May 07 '24 14:05 superhans2