[1.1.0] Robot Framework: how to use together with SikuliX (user keywords / test libraries)

Asked by balu

------ This is a setup that definitely works:

RFW = Robot Framework

--- preparations:
- have Python 2.7+ installed
- install RobotFrameWork using the respective installer (Windows installer.exe) (2.8+)
… now you have a useable RFW together with Python

since we want to use SikuliX features, you need
- an actual Java (recommended 7 or 8)
- install Jython or download the Jython standalone jar (needed 2.7b3)
- have a sikulixapi.jar created with setup (version 1.1.0+)

now create a command file jybot (or however you name it) wherever you want:

(this the Windows jybot.bat version, Mac and Linux users should be able to adapt ;-)

@echo off
setlocal
set ROBOT_HOME=<PythonInstallationFolder>/Lib/site-packages
set JYTHON_HOME=<folderContaining-jython.jar>
set SIKULIX_HOME=<folderContaining-sikulix.jar>

set CLASSPATH=%SIKULIX_HOME%sikulixapi.jar;%CLASSPATH%
set JYTHONPATH=%SIKULIX_HOME%sikulixapi.jar\Lib

java -cp %JYTHON_HOME%jython.jar;%CLASSPATH% org.python.util.jython ^
                %ROBOT_HOME%robot\run.py ^
                --pythonpath=<folderContainingLibraries>/someLibrary.sikuli ^
               %*
endlocal

--- usage to run tests
jybot.bat <…. any RFW parameters …> <pathToYourRFW-testFile>

This is only a showcase, to point out the key needs.
I used different folder variables for the participating stuff (RFW, Jython and SikuliX).
to allow, to use any other folder organization and adjust the variables as needed.

more actual information, test setups and help:
https://github.com/Tset-Noitamotua/Sikuli-and-Robot-Framework-Integration

-----------------------------------------------------------------------------------------------

Hi,

  I am following below blog to run calculator test in my windows 7.

http://blog.mykhailo.com/2011/02/how-to-sikuli-and-robot-framework.html?showComment=1422206385305#c361348174523267467

  Now I got stucked in STEP 2. I am getting following error:

C:\Users\test\Desktop\Projects\Sikuli Projects\calc.sikuli>robottest.bat verif
y_operations.txt
Exception in thread "main" Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\test\Desktop\Projects\Sikuli Projects\calc.sikuli\robotframew
ork-2.5.5.jar\Lib\robot\__init__$py.class", line 16, in <module>
  File "C:\Users\test\Desktop\Projects\Sikuli Projects\calc.sikuli\Lib\os.py",
 line 118, in <module>
    raise ImportError, 'no os specific module found'
ImportError: no os specific module found

C:\Users\test\Desktop\Projects\Sikuli Projects\calc.sikuli>

My robottest.bat content:

@echo off

set sikulix_jar=C:\robot\libs\sikuli-script.jar
set robot_framework_jar=C:\Users\symbol\Desktop\Projects\Sikuli Projects\calc.sikuli\robotframework-2.5.5.jar

java -cp "%robot_framework_jar%;%sikulix_jar%" ^
     -Dpython.path="%sikulix_jar%/Lib" ^
     org.robotframework.RobotFramework ^
     --pythonpath=calc.sikuli ^
     --outputdir=results ^
     --loglevel=TRACE ^
     %*

 Could anyone please guide me on this.

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

please follow the discussion in the mentioned post.
especially the latest ones by Tset-Noitamotua
and his work on github:
https://github.com/Tset-Noitamotua/Sikuli-and-Robot-Framework-Integration

Revision history for this message
balu (balu-networks7) said :
#2

Hi Raiman,

  Thanks for your reply.

I tried to use both the following one by one in verify_operations.txt:

Library calc.Calculator WITH NAME Calculator
Library C:/Users/symbol/Desktop/Projects/Sikuli Projects/calc.sikuli/calc.py

but still I am getting following error:

C:\Users\symbol\Desktop\Projects\Sikuli Projects\calc.sikuli>robottest.bat verif
y_operations.txt
[ ERROR ] Error in file 'C:\Users\symbol\Desktop\Projects\Sikuli Projects\calc.s
ikuli\verify_operations.txt': Importing test library 'calc.Calculator' failed: I
mportError: No module named sikuli
Traceback (most recent call last):
  File ".\calc.py", line 7, in <module>
    from sikuli import *
  File "C:\Users\symbol\Desktop\Projects\Sikuli Projects\calc.sikuli\Lib\sikuli\
__init__.py", line 3, in <module>
    from Sikuli import *
  File "C:\Users\symbol\Desktop\Projects\Sikuli Projects\calc.sikuli\Lib\sikuli\
Sikuli.py", line 10, in <module>
    from org.sikuli.script import SikuliScript
PYTHONPATH:
  C:\Users\symbol\Desktop\Projects\Sikuli Projects\calc.sikuli\robotframework-2.
8.5.jar\Lib\robot\libraries
  C:\Users\symbol\Desktop\Projects\Sikuli Projects\calc.sikuli\robotframework-2.
8.5.jar\Lib
  C:\jython2.5.4rc1\Lib
  C:\Users\symbol\Desktop\Projects\Sikuli Projects\calc.sikuli\Lib
  __classpath__
  __pyclasspath__/
  .
  C:\Users\symbol\Desktop\Projects\Sikuli Projects\calc.sikuli
CLASSPATH:
  C:\Users\symbol\Desktop\Projects\Sikuli Projects\calc.sikuli\robotframework-2.
8.5.jar
  C:\robot\libs\SikuliX_110\sikulixapi.jar
==============================================================================
Verify Operations
==============================================================================
Verify that 2 + 2 = 4 | FAIL |
No keyword with name 'Start App' found.
------------------------------------------------------------------------------
Verify that 2 + 2 = 5 | FAIL |
No keyword with name 'Start App' found.
------------------------------------------------------------------------------
Verify Operations | FAIL |
2 critical tests, 0 passed, 2 failed
2 tests total, 0 passed, 2 failed
==============================================================================
Output: C:\Users\symbol\Desktop\Projects\Sikuli Projects\calc.sikuli\results\ou
tput.xml
Log: C:\Users\symbol\Desktop\Projects\Sikuli Projects\calc.sikuli\results\lo
g.html
Report: C:\Users\symbol\Desktop\Projects\Sikuli Projects\calc.sikuli\results\re
port.html

C:\Users\symbol\Desktop\Projects\Sikuli Projects\calc.sikuli>

Could you please give me a idea to fix this.

Thanks in advance.
Hide

    History
    Link existing bug
    Create bug report
    Link to a FAQ
    Create a new FAQ

Message:

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

Please stay here with your own question.

as already mentioned:
https://github.com/Tset-Noitamotua/Sikuli-and-Robot-Framework-Integration

he got it working.

BTW: you need Jython and not Python !!

Revision history for this message
balu (balu-networks7) said :
#4

Hi Raiman,

   I am trying to have the same versions of software's that Mike mentioned in his blog:

System Configuration Setup:

    Windows 8.1 (German - but I plan to change that to English soon) - I using Windows 7
    Java version 1.8.0_05 (build 1.8.0_05-b13) can be JDK or JRE - I have this
    SikuliX 1.1.0 (nightly build 2015-01-16) ------ I have this
    Robot Framework 2.8.7 - I am using 2.8.5
    Python 2.7.3 - I am using 2.7.8
    Jython 2.7 beta3 (Jython 2.7b3)

I have downloaded "jython-installer-2.7-b3" from http://www.jython.org/downloads.html

I am unable to install this with command "java -jar jython-installer-2.7-b3". It was throwing "could not find the main class:org.python.util.install.installation. program will exist" error.

So I have copied this jar file in a folder, and extracted the contents in that folder. Then I gave that path as my "JYTHONPATH".

After that I am getting following error:

C:\Users\symbol\Desktop\Verify_Step2>robottest.bat "c:\Users\symbol\Desktop\Veri
fy_Step2\robot_suite\verify_operations.txt"
Exception in thread "main" Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\symbol\Desktop\Verify_Step2\robotframework-2.8.5.jar\Lib\robot\
__init__$py.class", line 43, in <module>
  File "C:\Users\symbol\Desktop\Verify_Step2\robotframework-2.8.5.jar\Lib\robot\
pythonpathsetter$py.class", line 17, in <module>
  File "C:\jython2.7beta3\Lib\os.py", line 64, in <module>
    import ntpath as path
  File "C:\jython2.7beta3\Lib\ntpath.py", line 12, in <module>
    import warnings
  File "C:\jython2.7beta3\Lib\warnings.py", line 6, in <module>
    import linecache
SyntaxError: ("'with' will become a reserved keyword in Python 2.6", ('C:\\jytho
n2.7beta3\\Lib\\linecache.py', 127, 8, ''))

C:\Users\symbol\Desktop\Verify_Step2>

Could you please tell me how to fix this.

And please suggest me a location where I can download " Robot Framework 2.8.7". I am unable to find this net.

Thanks in advance.

Revision history for this message
balu (balu-networks7) said :
#5

I mean "robotframework-2.8.7.jar" file.

I upgraded to "robotframework-2.8.7" using the following method:

C:\Users\symbol\Desktop\Verify_Step2>pip install --upgrade robotframework
Downloading/unpacking robotframework from https://pypi.python.org/packages/sourc
e/r/robotframework/robotframework-2.8.7.tar.gz#md5=42a38054fb24787e6d767e0a96315
627
  Running setup.py (path:c:\users\symbol\appdata\local\temp\pip_build_symbol\rob
otframework\setup.py) egg_info for package robotframework

    no previously-included directories found matching 'src\robot\htmldata\testda
ta'
Installing collected packages: robotframework
  Found existing installation: robotframework 2.8.1
    Uninstalling robotframework:
      Successfully uninstalled robotframework
  Running setup.py install for robotframework

    no previously-included directories found matching 'src\robot\htmldata\testda
ta'
    Removing C:\Python27\Lib\site-packages\robotframework-2.8.7-py2.7.egg-info
Successfully installed robotframework
Cleaning up...

C:\Users\symbol\Desktop\Verify_Step2>

But still I am facing same issue.

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

--- Jython
What about just double-clicking the installer jar?
But anyways: the standalone jar is sufficient.
When working with Sikuli, Python is not relevant (we need Jython).
Python might only help in preparations and installing prereqs with pip/easy-install/..., but the you have to create correct references to the created artifacts in the Python environment (usually site-packages)

--- RFW
version 2.8.5 surely is sufficient
about how to install and/or get the latest version:
https://github.com/robotframework/robotframework/blob/master/INSTALL.rst

where you get, when you start at
http://robotframework.org

--- your concrete problem
It seems, that you are still working with the old stuff from Mike.
I recommended, to work along
https://github.com/Tset-Noitamotua/Sikuli-and-Robot-Framework-Integration
there the with-future problem is fixed

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

ok, hat sich überschnitten.

Revision history for this message
balu (balu-networks7) said :
#8

Hi Raiman,

STEP 1:
=======

I am following same "https://github.com/Tset-Noitamotua/Sikuli-and-Robot-Framework-Integration". I have downloaded all files from here. And I upgraded Robot framework using "pip install robotframework" command as shown below:

C:\Users\symbol\Desktop\Verify_Step2>pip install --upgrade robotframework
Downloading/unpacking robotframework from https://pypi.python.org/packages/sourc
e/r/robotframework/robotframework-2.8.7.tar.gz#md5=42a38054fb24787e6d767e0a96315
627
  Running setup.py (path:c:\users\symbol\appdata\local\temp\pip_build_symbol\rob
otframework\setup.py) egg_info for package robotframework

    no previously-included directories found matching 'src\robot\htmldata\testda
ta'
Installing collected packages: robotframework
  Found existing installation: robotframework 2.8.1
    Uninstalling robotframework:
      Successfully uninstalled robotframework
  Running setup.py install for robotframework

    no previously-included directories found matching 'src\robot\htmldata\testda
ta'
    Removing C:\Python27\Lib\site-packages\robotframework-2.8.7-py2.7.egg-info
Successfully installed robotframework
Cleaning up...

C:\Users\symbol\Desktop\Verify_Step2>

STEP 2:
=======

I am getting following error when I double click on installer.jar:

 "could not find the main class:org.python.util.install.installation. program will exist"

I tried to use standalone jar from "JYTHONPATH". but still its throws same error.

Could you please tell me how to use "jython-standalone-2.7-b3.jar"?

Revision history for this message
balu (balu-networks7) said :
#9

Hi RaiMan,

Could you please guide me how to use "jython-standalone-2.7-b3.jar"?

Thanks,
Balu

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

Sorry, you have to wait, other priorities currently.

Revision history for this message
balu (balu-networks7) said :
#11

Sure RaiMan, I will wait for your reply.

Thanks for helping me in your busy schedule.

Thanks,
Balu.

Revision history for this message
balu (balu-networks7) said :
#12

Hi RaiMan,

     Not to rush you, Is it possible to help me to fix this issue if you get some free time today or tomorrow. :-)

     I am getting pressure from my manager to complete my automation project.

     Thanks for your help.

Thanks,
Balu

Revision history for this message
balu (balu-networks7) said :
#13

Now I have the same versions of software's that Mike mentioned in his blog : "https://github.com/Tset-Noitamotua/Sikuli-and-Robot-Framework-Integration."

Following is my system configuration now:
==================================

    - Windows 7 32 bit
    - Java version 1.8.0_31 (build 1.8.0_31) JRE
    - SikuliX 1.1.0
    - Jython 2.7 beta3 (Jython 2.7b3)
    - Robot Framework 2.8.7
    - Python 2.7.8.10

PATH Settings configured:
=====================

CLASSPATH : C:\robot\libs\SikuliX_110\sikulixapi.jar
JYTHONPATH : C:\jython2.7b3\Lib
PYTHONPATH : C:\Python27\Lib\
SIKULIX_HOME : C:\robot\libs\SikuliX_110\
PATH : C:\Users\symbol\Downloads\libs;C:\Tcl\bin;%APPDATA%\Python\Scripts;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;%PATH%;C:\MinGW\bin;C:\MinGW\mingw32\bin;C:\MinGW\msys\1.0\bin;C:\MinGW\msys\1.0\sbin;C:\jython2.7b3\bin;C:\Users\symbol\Desktop\Sikuli Install\Sikuli\Sikuli-X-1.0rc3 (r905)-win32\Sikuli-IDE\libs;C:\Program Files\Java\jre1.8.0_31\bin;%SIKULIX_HOME%;%SIKULIX_HOME%libs;C:\Python27\Scripts

My robottest.bat contents:
======================

@echo off

set sikulix_jar=C:\robot\libs\SikuliX_110\sikulixapi.jar
set robot_framework_jar=C:\Users\symbol\Desktop\Verify_Step2\robotframework-2.8.7.jar

java -cp "%robot_framework_jar%;%sikulix_jar%" ^
     -Dpython.path="%sikulix_jar%/Lib" ^
     org.robotframework.RobotFramework ^
     --pythonpath=calc.sikuli ^
     --outputdir=results ^
     --loglevel=TRACE ^
     %*

My "verify_operations.txt" contents:
=============================

***Settings***

Library C:/Users/symbol/Desktop/Verify_Step2/calc.sikuli/calc.py

***Test Cases***
Verify that 2 + 2 = 4
 Start App
 Verify App
 Perform Action 2 + 2
 Verify Result 4

Verify that 2 + 2 = 5
 Start App
 Verify App
 Perform Action 2 + 2
 Verify Result 5

Now If run the test, I am getting following error:

C:\Users\symbol\Desktop\Verify_Step2>robottest.bat "c:\Users\symbol\Desktop\Veri
fy_Step2\robot_suite\verify_operations.txt"
Exception in thread "main" Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\symbol\Desktop\Verify_Step2\robotframework-2.8.7.jar\Lib\robot\
__init__$py.class", line 43, in <module>
  File "C:\Users\symbol\Desktop\Verify_Step2\robotframework-2.8.7.jar\Lib\robot\
pythonpathsetter$py.class", line 17, in <module>
  File "C:\jython2.7b3\Lib\os.py", line 64, in <module>
    import ntpath as path
  File "C:\jython2.7b3\Lib\ntpath.py", line 12, in <module>
    import warnings
  File "C:\jython2.7b3\Lib\warnings.py", line 6, in <module>
    import linecache
SyntaxError: ("'with' will become a reserved keyword in Python 2.6", ('C:\\jytho
n2.7b3\\Lib\\linecache.py', 127, 8, ''))

C:\Users\symbol\Desktop\Verify_Step2>

Please help me to fix this issue in your free time.

Thanks,
Balu.

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

Ok, I went through the stuff I pointed you to this morning and found it is a bit weird.

This is a setup that definitely works:

--- preparations:
- have Python 2.7+ installed (ok, you have Python 2.7)
- install RobotFrameWork using the respective Windows installer.exe (I think you have nothing to do, since you already have a running RFW in your Python environment)
- download the Jython 2.7b3 standalone jar (you have it I think)
- have a sikulixapi.jar created with setup (latest nightly, I think you have it

--- make a test setup with RFW
- create a folder (e.g. c:\RFW)
- into this folder copy the python…jar
- into this folder copy the calc.sikuli from the github site mentioned, take the one from step_2
- into this folder copy sikulixapi.jar
- into this folder copy the verify_….txt again from the github site and from step_2
- from the Python installation folder at Lib/site-packages copy the complete subfolder robot

now you should have this in the test setup folder:
calc.sikuli
robot
jython….jar
sikulixapi.jar
verify_….txt

now create a file jybot.bat (or however you name it) in this folder with this content:

@echo off
setlocal
set ROBOT_HOME=%~dp0
set JYTHON_HOME=%ROBOT_HOME%
set SIKULIX_HOME=%ROBOT_HOME%

set CLASSPATH=%SIKULIX_HOME%sikulixapi.jar;%CLASSPATH%
set JYTHONPATH=%SIKULIX_HOME%sikulixapi.jar\Lib

java -cp %JYTHON_HOME%jython.jar;%CLASSPATH% org.python.util.jython ^
  %ROBOT_HOME%robot\run.py ^
  --pythonpath=%ROBOT_HOME%calc.sikuli ^
  %*
endlocal

now being in this folder use
jybot.bat verify….txt

to run the test and have the result files in this folder.

This is only a showcase, to point out the key needs.
I already used different folder variables for the participating stuff (RFW, Jython and SikuliX).
feel free, to use any other folder organization and adjust the variables as needed.

Hope it is not too late to satisfy your boss ;-)

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

fuc…. auto-correct.

--- make a test setup with RFW
- create a folder (e.g. c:\RFW)
- into this folder copy the jython…jar
- into this folder copy the calc.sikuli from the github site mentioned, take the one from step_2
- into this folder copy sikulixapi.jar
- into this folder copy the verify_….txt again from the github site and from step_2
- from the Python installation folder at Lib/site-packages copy the complete subfolder robot

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

the jybot.bat can be run from anywhere

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

… but the calc.sikuli as it is setup, needs the RFW test to be run being in the test folder (otherwise the images would not be found).

In a real production environment the .sikuli libraries should be organized as a tree with a main library, that imports other libs as needed (environment settings or any other suitable way) and one should have an image repository which is pointed to by addImagePath() (no images in the library.sikuli).

Revision history for this message
balu (balu-networks7) said :
#19

Thanks RaiMan,

I will try the above things that you mentioned above and let you know the result.

Thanks once again for your timely help.

Revision history for this message
balu (balu-networks7) said :
#20

Hi RaiMan,

   I did the same thing step-by-step that you mentioned above.

   I am getting following error:

C:\RFW>jybot.bat verify_operations.txt
Error: Could not find or load main class org.python.util.jython

C:\RFW>

Revision history for this message
balu (balu-networks7) said :
#21

Hi RaiMan,

 I given "java -cp %JYTHON_HOME%jython-standalone-2.7-b3.jar;%CLASSPATH% org.python.util.jython ^" in jybot.bat file.

Its working now.

C:\RFW>jybot.bat verify_operations.txt
==============================================================================
Verify Operations
==============================================================================
Verify that 2 + 2 = 4 | PASS |
------------------------------------------------------------------------------
Verify that 2 + 2 = 5 | PASS |
------------------------------------------------------------------------------
Verify Operations | PASS |
2 critical tests, 2 passed, 0 failed
2 tests total, 2 passed, 0 failed
==============================================================================
Output: C:\RFW\output.xml
Log: C:\RFW\log.html
Report: C:\RFW\report.html

C:\RFW>

Seeing small errors. But i will fix that (2+2=5).

Thanks Thanks Thanks so much for your timely help. Really you are GREAT.

Thanks,
Balu.

Revision history for this message
balu (balu-networks7) said :
#22

Thanks RaiMan, that solved my question.

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

Danke für die Blumen und alles Gute.
Du bist jederzeit willkommen.