Feb 7, 2011

How-To: Sikuli and Robot Framework Integration


Introduction
Integration Details
Step 0: Installation
Step 1: Run Sikuli Script from command line
Step 2: Upgrade Sikuli Scripts to Test Libraries
Step 3: Tips and Tricks
Summary
References

Introduction

Sikuli and Robot Framework are both freely available open source tools that provide interesting possibilities for automation testers, QA and other IT people.

Sikuli introduces new way of automated testing - test using screenshots and images, without using any internal API of objects under test. This approach (using purely images/screenshots and generating mouse and keyboard events) is more similar to manual testing activities performed by real people which have just monitor, mouse and keyboard.

Robot Framework is an excellent implementation of keyword- and data-driven approaches to test automation and besides it includes a lot of interesting features and tools, such as:
and much more...

Integration Details

Robot Framework is written on python and provides tools for running test cases using either python or jython. Sikuli scripts are run using jython.
Taking into account all statements above, it is possible to run test cases using "jybot" tool, where keywords are implemented in Sikuli scripts. In other words, Sikuli scripts will play role of Test Libraries for Robot Framework.

Pic. 1 - Sikuli and Robot Framework Integration Architecture

The following integration how-to is splited on four main steps:
  1. Installation
  2. Run Sikuli Scripts using command line
  3. Upgrade Sikuli Scripts to Test Libraries
  4. Tips and tricks
Step 0: Installation

First of all this how-to is for Windows XP SP3, although everything should work on Windows 7 also.
The following software should be installed on your test machine:

1) Java Runtime Environment (JRE 6_23) to run jython scripts.
2) Jython 2.5.1 itself.
3) Python 2.7.1 (it is required by Robot Framework exe distribution. See a note below).
4) Robot Framework 2.5.5 (exe distribution)
5) Sikuli X.

NOTE: It is actually possible to install the framework using Jython without having Python installed at all, but this requires using the source distribution. More information could be found on the Instalation wiki page.

In case you are planning to use RobotFramework2.5.5.jar instead of installing the exe distribution you only need JRE and Sikuli X because Jython is already packed in RobotFramework2.5.5.jar.

Step 1: Run Sikuli Script from command line

Lets write simple Sikuli script for testing standart Windows calculator:


I assume that you made following screenshots:

  • calcApp.png  - screenshot of Calculator application
  • btn2.png, btnC.png, ... - screenshot of corresponding buttons of the calculator
So far you should be able to run this Sikuli script from Sikuli IDE. 

All what we want now is to be able to run this script from the command line without using Sikuli IDE.

Sikuli 10.2
Here you can find detailed tutorial with steps and settings required for using Sikuli 10.2 from the command line. Briefly, what we should do according to the tutorial above:
  1. Copy sikuli-script.jar from Sikuli installation directory (by default "C:\Program Files\Sikuli") to the directory of your Sikuli project.
  2. Extract "Lib" directory from sikuli-script.jar to the directory of your Sikuli project.
  3. Add the following statement to the beginning of your Sikuli script:
     1 from sikuli.Sikuli import *
     2 
    
As a result your Sikuli project layout should look as below:

Pic. 2 - Sikuli project layout

runtest.bat file is a batch file for running your Sikuli script:

NOTE: Above steps, as you may notice, is for Sikuli version 10.2. For Sikuli X we need extra steps described below.

Sikuli X
  1. Copy libs from Sikuli installation (by default: C:\Program Files\Sikuli X\libs) to the Temp directory (C:\Documents and Settings\Local Settings\Temp\tempdir\).
Actually path to the Sikuli libs is added to the Path environment variable, but in my case I get java.lang.UnsatisfiedLinkError unless I copy these libraries.
  1. Add path to the JRE bin directory (by default: C:\Program Files\Java\jre6\bin) to the Path environment variable.
Starting from Sikuli X some Java dll-s are required by Sikuli libraries. For example: Win32Util.dll depends on jawt.dll.

That's all what you need to be able to run your Sikuli script from the command line. One more thing here (I noticed, when I was writing this How-To):

NOTE: Using Sikuli X you can skip steps 1 and 2 (coping sikuli-script.jar and Lib directory) and just run your Sikuli script using following command. You even do not need explicitly to indicate path to the Lib directory as it is automatically added to the PYTHONPATH variable.

 C:\work\> java -jar "C:\Program Files\Sikuli X\sikuli-script.jar" calc.sikuli




2. Upgrade Sikuli Scripts to Test Libraries

Now we can run our Sikuli script using Java Runtime Environment. To use our script from Robot Framework it should be updated to support one of available Library APIs.

According to the Robot Framework User Guide, Library Static API:
The simplest approach is having a module (in Python) or a class (in Python or Java) with methods which map directly to keyword names. Keywords also take the same arguments as the methods implementing them. Keywords report failures with exceptions, log by writing to standard output and can return values using the return statement.
Taking into account all above our Sikuli script is already a Test Library implemented using Static API. Thus no further changes required except one line of code in order to find images/screenshots:

 3 
 4 addImagePath("calc.sikuli")
 5 

addImagePath() has been added since Sikuli X, for older version of Sikuli use setBundlePath() instead.

What we need now that is to write a new Test Case for Robot Framework using keywords from the Sikuli script.


Lets place this test case under robot_suite directory. At this point, there are two way of using Robot Framework:

  • use robotframework-2.5.5.jar without any further installation.
  • install robotframework-2.5.5.exe and use jybot.bat.
    For this case, Python (required by Robot Framework exe distribution) and Jython (required by jybot) should be installed.


Run test cases using robotframework.jar.
  1. Download robotframework-2.5.5.jar file and place it to your Sikuli project directory.
  2. Run test cases using robottest.bat file, that is shown below, using command:
  3.  C:\work\> robottest.bat robot_suite\verify_operations.txt
    
    
Below is the content of robottest.bat. As you can see, this is simple run of java command with CLASSPATH parameter, that import two jar files and some extra parameters for Robot Framework: such as where to put logs and reports, log level and path to your Sikuli script added to python path.



Run test using jybot.bat.
  1. Install Python, Jython and Robot Framework
  2. Add pathes to Python/Script (jybot.bat is there) and Jython (jython.bat is there) directories to the PATH environment variable (by default "C:\Python27\Scripts;C:\jython2.5.1")
  3. Run test cases using jybottest.bat file, that is shown below, using command:
  4.  C:\work\> jybottest.bat robot_suite\verify_operations.txt
    
    
This is the content of jybottest.bat. Here JYTHONPATH variable contains path to the Lib directory under sikuli-script.jar file.

That's all what you need to be able to run test cases that consist of keywords implemented by Sikuli scripts from Robot Framework. What to use: robotframework.jar or jybot.bat to run your test cases - depends on you and requirements of the project.

3. Tips and tricks

So far we easily can edit our Sikili scripts in Sikuli IDE, edit our test cases in Robot IDE and run all that from the command line.

What is explained in this section?
- Benefits that we can achieve from Sikuli and Robot Framework Integration, particularly detailed logs, that are accompanied by screenshots.
Such logs can significantly decrease time for result analysis, to find the reasons of failures and errors in the test suite.

Here is the example of log file where Find Failed Exception raised by Sikuli is used for getting info about a source image and a region within this image was searched.

Pic. 3 - Robot Framework log file with screenshoots

Implementation of such logging features is quite simple. All what we need is 
  • a wrapper for the Sikuli functions and classes 
  • a custom Robot Logger class

Lets have a deep look at both.


Global Sikuli functions, e.g. click(), exists(), find() that are actually methods of Screen class are moved to the global level using a hack (manually push methods to the internal globals dictionary, for details).
To wrap these global functions we can use similar hack. Look at code below:

 9 
10 # =============================================== #
11 #          Overwritten sikuli methods             #
12 # =============================================== #
13 
14 # function for calling native sikuli methods
15 def sikuli_method(name, *args, **kwargs):
16     return sys.modules['sikuli.Sikuli'].__dict__[name](*args, **kwargs)
17 
18 # overwritten Screen.exists method
19 def exists(target, timeout=None):
20     addFoundImage(getFilename(target))
21     return sikuli_method('exists', target, timeout)
22 

Here sikuli_method() is a way to call native Sikuli global function and exists() is an example of overwritten method.

Even easier situation is with Sikuli classes. You can extend them in natural object oriented way. What you need is just to import Sikuli class with alternative name (for example SikuliRegion), in order to use original name (for example Region) in Sikuli scripts. have a look at code below.

 3 from sikuli.Sikuli import Region as SikuliRegion

23 # =============================================== #
24 #          Overwritten sikuli classes             #
25 # =============================================== #
26 
27 # overwriten Sikuli Region class
28 class Region(SikuliRegion, BaseLogger):
29 
30     def click(self, target, modifiers=0):
31         try:
32             return SikuliRegion.click(self, target, modifiers)
33         except FindFailed, e:
34             self.log.html_img("Find Filed", "images/" + getFilename(target))
35             self.log.screenshot(msg="Region", region=(self.getX(), self.getY(), self.getW(), self.getH()))
36             raise e
37     def exists(self, target, timeout=None):
38         img = getFilename(target)
39         reg = (self.getX(), self.getY(), self.getW(), self.getH())
40         addFoundImage(img, reg)
41         return SikuliRegion.exists(self, target, timeout)


So far we have our overwritten Sikuli methods and as you may notice have a possibility to use them in Sikuli scripts - no changes required to our Sikuli scripts, except importing sikuliwrapper module instead of sikuli.Sikuli.

The purpose of the Sikuli wrapper module is to gather an additional info about what image is being searched and a region within it is being looked for. Such information later is used by Robot Logger.

Robot Logger


Robot Logger is an derived class from Python's standard Logger class from logging module.
What is added there is the following:

  • a custom handler for printing messages in Robot Framework's style, e.g. "*INFO* Message text"
  • special methods for passed and failed statuses of test cases
  • methods for making screenshots of desired regions and adding them as html records to the Robot log
The whole logger.py file can be found here


Summary

I tried to show how easy to work with open source test automation tools where all undocumented problems can be solved in one quick look into source code, in spite of limitation you may find with similar commerce tools.

I really like both Sikuli and Robot Framework tools, and hope this how-to describes some of their advantages, its flexibly and extendability.

I added all code mentioned here on github. Feel free to clone and have a look at it.

I look forward to hearing from you, especially about your tips and tricks with these amazing tools.


References

123 comments:

  1. Thank you, Andriy Kolodiy for review of this blog post. I owe you beer!

    ReplyDelete
  2. Mad props Mike, this is testing goodness!

    ReplyDelete
  3. getting following error :

    KEYWORD: Calculator.Verify App
    Start / End / Elapsed: 20110717 17:44:49.467 / 20110717 17:44:50.467 / 00:00:01.000
    17:44:49.467 TRACE Arguments: [ ]
    17:44:50.437 INFO PASS: Calculator window appeared
    17:44:50.437 INFO Source Image
    17:44:50.467 FAIL IOError: [Errno 13] EACCES: 'results/matches/2011-07-17_17-44-50.png'
    17:44:50.467 DEBUG Traceback (most recent call last):
    File "C:\devs\calctest\robotframework-2.5.5.jar\Lib\robot\running\keywords$py.class", line 106, in _run
    File "C:\devs\calctest\robotframework-2.5.5.jar\Lib\robot\running\handlers$py.class", line 104, in run
    File "C:\devs\calctest\robotframework-2.5.5.jar\Lib\robot\running\handlers$py.class", line 116, in _run
    File "C:\devs\calctest\robotframework-2.5.5.jar\Lib\robot\running\handlers$py.class", line 127, in _run_with_output_captured_and_signal_monitor
    File "C:\devs\calctest\robotframework-2.5.5.jar\Lib\robot\running\handlers$py.class", line 138, in _run_with_signal_monitoring
    File "C:\devs\calctest\robotframework-2.5.5.jar\Lib\robot\running\handlers$py.class", line 122, in
    File "CalcLib\calc.py", line 23, in verifyApp
    self.log.passed("Calculator window appeared")
    File "CalcLib\logger.py", line 52, in passed
    self.screenshot(msg="Best Matches", folder='results/matches/', region=region)
    File "CalcLib\logger.py", line 40, in screenshot
    shutil.copy(img_src, folder + name)
    File "C:\Program Files\Sikuli X\sikuli-script.jar\Lib\shutil.py", line 85, in copy
    copyfile(src, dst)
    File "C:\Program Files\Sikuli X\sikuli-script.jar\Lib\shutil.py", line 52, in copyfile
    fdst = open(dst, 'wb')

    ReplyDelete
  4. It seems that user used for running the test does not have write access to the results/matches/' directory or this directory does not exist, so screenshot can't be copied to this directory.

    ReplyDelete
  5. I just found something similar for Python. Would be interesting if you or someone did an eval of the tool along with integration with Robot Framework as well.

    http://blog.labix.org/2010/05/18/xpresser-python-library-for-gui-automation-with-image-matching

    ReplyDelete
  6. Is there MAC version?

    ReplyDelete
  7. No, there is no MAC version yet. I'll add it soon if needed.

    ReplyDelete
  8. This comment has been removed by a blog administrator.

    ReplyDelete
  9. Hi,

    I am getting the following error:

    No keyword with name 'click' found.

    Subha

    ReplyDelete
  10. No keyword found error happens when test library is not initialized properly, in other words if there are errors in library, e.g. syntax errors.
    As a result library can not be used and all keywords implemented in it are not visible for Robot Framework.
    If you provide more details about error then I'll try to help.

    ReplyDelete
  11. Hi,
    I have two code - which is definetly developed from urs:
    ========= 1st ONE ====================
    Here the problem is I am able to take the screen shot but it is not getting attached to the log file generated by 'Robot' Frame work:

    from logger import *
    import common
    from sikuli.Sikuli import *
    from sikuli.Sikuli import Region as SikuliRegion

    log = RobotLogger()
    match = Screen()

    addImagePath("D:\\Sikuli\\Charts.sikuli")

    def sikClick(target):
    try:
    return click(target)
    except FindFailed, e:
    log.html_img("Find Filed", "C:/GRIDTRIAL/Sikuli/" + getFilename(target))
    log.screenshot(msg="Region", region= (match.getX(), match.getY(), match.getW(), match.getH()))
    raise e

    ReplyDelete
  12. Here is the 2nd one about which I told u:
    ******************xxxxxxxxxx******************
    from logger import *
    import commonsikuli as common
    from sikuli.Sikuli import Region as SikuliRegion

    addImagePath("D:\\Sikuli\\Charts.sikuli")

    if common.cfgLoggingLevel.lower() == 'debug':
    setShowActions(True)

    class Region(SikuliRegion, BaseLogger):

    def sikClick(self, target, modifiers=0):
    try:
    return SikuliRegion.click(self, target, modifiers)
    except FindFailed, e:
    self.log.html_img("Find Filed", "C:/GRIDTRIAL/Sikuli/images/" + getFilename(target))
    self.log.screenshot(msg="Region", region=(self.getX(), self.getY(), self.getW(), self.getH()))
    raise e

    def sikFind(self, target):
    img = getFilename(target)
    reg = (self.getX(), self.getY(), self.getW(), self.getH())
    addFoundImage(img, reg)
    return SikuliRegion.find(self, target)

    ********************xxxxxxxxxxxxxx************
    Now I made a small chage in the logger file as I am getting the following error:

    File "C:\Python27\Lib\logger.py", line 29, in __init__
    if common.cfgLoggingLevel.lower() == 'debug':

    I changed the common.py to commonsikuli & imported as:"import commonsikuli as common"
    ***********xxxxxxxxxxxxxx*************

    I have made this file as library file in 'Robot' frame work and called these functions as key words;

    Thanks for ur time

    Regards
    Subh

    ReplyDelete
  13. Here is the 1st one (which I posted in the blog but got lost)

    ***************xxxxxxxxxxxxxxxx***********
    Here the porblem is it taking the screen shot but not attaching it to the log file, generated by 'Robot framework'

    from logger import *
    import commonsikuli as common
    from sikuli.Sikuli import *

    log = RobotLogger()
    match = Screen()

    addImagePath("D:\\Sikuli\\Charts.sikuli")

    if common.cfgLoggingLevel.lower() == 'debug':
    setShowActions(True)

    def sikClick(target):
    try:
    return click(target)
    except FindFailed, e:

    log.html_img("Find Filed", "C:/GRIDTRIAL/Sikuli/" + getFilename(target))
    log.screenshot(msg="Region", region= (match.getX(), match.getY(), match.getW(), match.getH()))
    raise e


    This code is also developed from ur code too;

    Thanks for the help

    Regards
    Subh

    ReplyDelete
  14. Hi Mykhailo Moroz,

    I was able to solve the problem where it is taking the screen shot but not attaching it to the log file.

    Regards
    Subh

    ReplyDelete
  15. It also looks like one could try to build a Java library for Sikuli for use with Robot Framework rather than go through Jython/Python as library implementation. However, you would still have to run Robot Framework via Jython for that, unless you run the Java (or the currenty Jython example) library as a remote library.

    How to use Sikuli Script in your JAVA programs
    http://sikuli.org/docx/faq/030-java-dev.html

    ReplyDelete
  16. Definitely good point. Remote library API is another strong side of Robot Framework :)

    ReplyDelete
  17. Hi Mike, first of all I´d like to say Congratulations for the blog and tuto, second one I am having a trouble when I am running the Robot through the jybottest.bat batch I´ve got the following error message:
    "[ERROR] Invalid syntax in file 'c:\Library\robot_suite\verify_opertions.txt' in table 'Settings: Non-existing 'Library calc.Calculator WITH NAME Calculator '"

    I will appreciate with you help to fix that one.

    I have the following directory structure:
    Library\
    CalcLib\calc.py
    robot_suite\verify_operations.txt

    I´ve instaled Python 2.6 and Jython 2.5.1
    I have on the path= C:\Python27;C:\Jython2.5.1\bin
    jython="C:\jython2.5.1\bin\jython.bat"

    I can run the sikuli script without errors from CMD.

    My issue it´s with run it over Robot.

    Thanks and Regards,
    Thiago Peçanha

    ReplyDelete
  18. Hi Thiago,
    The error message says that robot can not find calc test library, in other words calc.py file is not in PYTHONPATH.

    As you can see inside jybottest.bat (https://github.com/imikemo/Sikuli-and-Robot-Framework-Integration/blob/master/calctest/jybottest.bat) it adds CalcLib to the PYTHONPATH and it assumes that CalcLib folder exists in the current workspace.

    In your case CalcLib folder is moved into Library folder, so you should add proper folder to the PYTHONPATH.
    Try to update the corresponding line in jybottest.bat:
    jybot --pythonpath=Library/CalcLib ^

    ReplyDelete
  19. Just wanted to mention for those interested, it would be more preferable and usable for the test community at large to make a generic SikuliLibrary rather than a custom library like in this tutorial. I'm working on one, and if can release as open source, will do so.

    Otherwise, it's pretty easy for one to do oneself. Just build a library like in this tutorial but the methods or functions will simply be wrappers to the Sikuli API. Unless doing a full port/support of Sikuli, one only needs to wrap parts of the Screen and/or Region API for stuff like click, type, exists, wait, all against a specified PNG image representing the object.

    http://sikuli.org/doc/java-x/

    The Java API is pretty good, though it could use more clarification in certain areas to elaborate on what the different class types are about w/o needing to look through the whole site, etc. I've found easiest to just stick to the Screen and Region APIs and defer the rest.

    ReplyDelete
  20. Hello,

    This post has been very enlightening thanks!

    I'm also having trouble getting the robotframework to find CalcLib in my PYTHONPATH.

    I can run the calc.sikuli from the commandline without errors. I'm on Windows7.

    My directory structure is:
    C:\test\CalcLib\calc.py
    C:\test\robotframework-2.6.0.jar
    C:\test\robot_suite\verify_operations.txt
    C:\Program Files\Sikuli X\sikuli-script.jar

    My robototest.bat is like this:


    @echo off

    set sikuli_jar=C:\Program Files\Sikuli X\sikuli-script.jar

    java -cp "robotframework-2.6.0.jar;%sikuli_jar%" ^
    -Dpython.path="%sikuli_jar%/Lib" ^
    org.robotframework.RobotFramework ^
    --pythonpath=CalcLib ^
    --outputdir=results ^
    --loglevel=TRACE ^
    %*

    can you please tell me what i'm doing wrong?

    ReplyDelete
  21. I should mention that I'm getting this error when running the cmd

    robottest.bat robot_suite\verify_operations.txt

    [ ERROR ] Invalid syntax in file 'c:\test\robot_suite\verify_operations.txt' in table 'Settings': Non-existing setting 'Library calc.Calculator WITH NAME Calculator'.

    ReplyDelete
  22. Hi,

    It seems everything is right with your directory structure and robottest.bat.
    I suspect problem is inside calc.py test library, if it contains errors or bad import statements then it could be the reason for this error. Try to download all files into CalcLib folder from GitHub: sikuliwrapper.py, common.py, logger.py (https://github.com/imikemo/Sikuli-and-Robot-Framework-Integration/tree/master/calctest/CalcLib)

    Another possible reason could be a newer version of Robot Framework. I used rf-2.5.5 for examples in this blogpost. Please try to use robotframework-2.5.5 instead of 2.6.0 - if this is reason for your issue then email me and I will update examples for 2.6.0.

    ReplyDelete
  23. Thanks for the response. I still cannot get it to work.

    from github, i copied all the files into my CalcLib folder. i'm also using robotframework-2.5.5.jar and updated my robottest.bat to reflect this change. my dir structure now looks like:

    c:\test\CalcLib\calc.py
    c:\test\CalcLib\common.py
    c:\test\CalcLib\logger.py
    c:\test\CalcLib\sikuliwrapper.py
    c:\test\robotoframework-2.5.5.jar
    c:\test\robottest.bat
    C:\test\robot_suite\verify_operations.txt
    C:\Program Files\Sikuli X\sikuli-script.jar

    i'm still getting the same errors. any other ideas on troubleshooting this?

    ReplyDelete
  24. Aha! I figured it out. For some reason the text editor I used lost the formatting of the whitespace in verify_operations.txt. i downloaded verify_operations.txt again and made sure the whitespace was preserved and now everything is working. Thanks for your help!

    ReplyDelete
  25. Hi Mikha, I was not able to run the script as I said you then I tried to download everything from your repositorie and tried to run it, everything goes right... Thanks a lot for the help, now I am gonna attempt to implement these awesome stuff in one of my projects.

    Just to let you know I ran it on:
    Robot_2.5.7

    Thanks a lot.

    ReplyDelete
  26. Hi everyone,

    has the command prompt ever crashed for you guys? sometimes when i'm running larger scripts, it will crash in the middle of a test run stopping all execution of test cases. any workarounds to this?

    thanks!

    ReplyDelete
  27. Any idea how to get this to work with the just released RC3?

    Here's the error I get when I run C:\test\> robottest.bat robot_suite\verify_operations.txt

    Exception in thread "main" Traceback (most recent call last):
    File "", line 1, in
    File "C:\test\robotframework-2.5.5.jar\Lib\robot\__init__$py.class", line 16, in
    File "C:\Program Files\Sikuli X\sikuli-script.jar\Lib\os.py", line 118, in
    ImportError: no os specific module found


    i also tried roobotframework-2.6.0.jar file with no success. I am going to downgrade back to RC2 for now, but I would like the bugfixes that comes with RC3. Any ideas?

    Thanks.

    ReplyDelete
  28. @nomdeplume i did the next to robottest.bat:

    -Dpython.path=..\robotframework-2.6.0.jar\Lib;"%sikuli_jar%/Lib" ^

    And now the sikuli RC3 is working with RF.

    ReplyDelete
  29. Anybody who want to try Sikuli library with Robot Framework as a Java library than Python? I could use some help figuring out how to get it fully working. Right now, it works as remote library but not local Java library running via Jython with Robot Framework...

    http://code.google.com/p/simplesikuli/

    ReplyDelete
  30. Anybody over here get it running over RIDE ? If so, what you did to get it running without errors ?

    Any help from the mates, please ?

    Regards,
    Thiago Felipe Peçanha

    ReplyDelete
  31. @man9ar00 I'll check the library when I get a chance.

    ReplyDelete
  32. Thiago,

    You can setup a run configuration in RIDE to use custom script instead of pybot/jybot. Try to use robottest.bat or jythontest.bat scripts mentioned in this blog post.

    ReplyDelete
  33. Hi, Congrats for the great job done here.
    I'm experiencing some problems on my win 7 64bit though. I installed the latest versions of jython (2.5.2), python (2.7.2), robot framework (2.6.2 64bit) and sikulix RC2. I cannot even start the sikuli-script.jar file. It seems like a link problem, but don't know how to solve it. There's a huge exception that starts and ends like below. Does anyone know what the problem might be?
    Traceback (most recent call last):
    File "", line 1, in
    File "D:\Automation\SikuliX\sikuli-script.jar\Lib\sikuli\__init__.py", line 1,
    in
    File "D:\Automation\SikuliX\sikuli-script.jar\Lib\sikuli\Sikuli.py", line 20,
    in
    java.lang.UnsatisfiedLinkError: D:\Automation\SikuliX\libs\VisionProxy.dll: Can'
    t find dependent libraries
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(Unknown Source)


    .....

    java.lang.UnsatisfiedLinkError: java.lang.UnsatisfiedLinkError: D:\Automation\Si
    kuliX\libs\VisionProxy.dll: Can't find dependent libraries

    ReplyDelete
  34. Solved the above issue. I discovered there were 2 JREs installed on this machine (jre6 and jre7). It seems that the whole thing got confused. It worked after I reverted the machine and installed only one jre.

    I have another question which is more general. Let's say that I want to run 100 tests. After they-re done, I discover that a lot of them were failed (let's say 40). Is there any built-in way to run only these 40 and update the earlier created log/report?
    At the moment, if I do this, I will get another output.xml, therefore another report and another log.

    Thanks

    ReplyDelete
  35. Radu,

    This is question to the developers of Robot Framework. I would suggest asking it on http://groups.google.com/group/robotframework-users?hl=en.

    As far as I know, you can't run the tests that previously failed such as this information is not saved anywhere. However such information could be parsed from output.xml file, but such solution will require you to write a parser.

    You can also check this list [1] of tools that are already available to see if nay of them will help you with merging output.xml files.

    Also build-in rebot script [2] that is intended to merge outputs of few lower level test suites into one higher level suite.

    [1] http://code.google.com/p/robotframework/wiki/SupportingTools
    [2] http://robotframework.googlecode.com/hg/doc/userguide/RobotFrameworkUserGuide.html?r=2.6.2#additional-options-for-post-processing-outputs

    Regards,
    Mykhailo

    ReplyDelete
  36. Thanks a lot for the info.
    [1] if there isn't any tool, i'll make it and post it somewhere
    [2] i think small modification can be made here. will keep you updated

    Thanks again

    ReplyDelete
  37. Coming back with some updates on what I found. There was an issue raised by the users regarding selecting failed tests and rerunning them. It also has some small .py file attached from one of the users as a workaround until this issue will be built-in
    http://code.google.com/p/robotframework/issues/detail?id=702 [used it and worked like a charm]

    Now another problem is 'what happens to the results if a power failure stops the suite from execution?' :)

    ReplyDelete
  38. Got a workaround for the power failure issue. I use the --debug option and generate a debug file with timestamped entries. It works great if the generated file is .html because it contains also html tags for images.

    I have another question though: when using jython to run the suite, after the jython is executed, no other thing from the batch file is executed. I have ope other copy command in the batch file and it never gets to it.
    Do you know what might cause this behavior? Check it with your jybot script and it was the same.

    ReplyDelete
  39. Hi. I was able to follow the instruction on Windows XP SP3 to run Robot Framework with Sikuli X-1.0rc2. I had to make few changes however:

    def startApp(self):
    calcApp = App("Calculator")
    if not calcApp.window():
    App.open("calc.exe"); wait(2)
    calcApp.focus(); wait(1)

    Here calcApp = App("Calculator") did not work for me. I am using a Korean Windows and using Korean equivalent for Calculator did not work. So instead, I

    def startApp(self):
    if exists("calculator.png"):
    print("Calculator is found.")
    else:
    calcApp = App.open("calc.exe"); wait(2)
    calcApp.focus(); wait(1)

    Another change I had to make was:

    def verifyResult(self, *args):
    expected_result = str(eval(''.join(args)))
    actual_result = self.getResultFromClipboard()

    #verification
    if actual_result == expected_result:
    print("PASS: Action performed correctly and result equals %s" % expected_result)
    else:
    print("FAIL: Actual result '%s' is not equal to expected result '%s'" % (actual_result, expected_result))
    raise AssertionError('Actual and expected results are different!')

    Here I added "raise AssertionError" if actual and expected results were different.

    So it worked well with RC2 but not with RC3. With RC3, I got following messages:

    D:\Sikuli\RobotFramework>robottest.bat robot_suite\verify_operations.txt
    Exception in thread "main" Traceback (most recent call last):
    File "", line 1, in
    File "D:\Sikuli\RobotFramework\robotframework-2.5.5.jar\Lib\robot\__init__$py.class", line 16, in
    File "D:\Program Files\Sikuli X\sikuli-script.jar\Lib\os.py", line 118, in
    ImportError: no os specific module found

    My robottest.bat looks like the following:

    @echo off
    set sikuli_jar=D:\Program Files\Sikuli X\sikuli-script.jar
    java -cp "robotframework-2.5.5.jar;%sikuli_jar%" ^
    -Dpython.path=..\robotframework-2.5.5.jar\Lib;"%sikuli_jar%/Lib" ^
    org.robotframework.RobotFramework ^
    --pythonpath=calc.sikuli ^
    --outputdir=results ^
    --loglevel=TRACE ^
    %*

    ReplyDelete
    Replies
    1. I think you should set like that
      -Dpython.path="robotframework-2.5.5.jar\Lib;%sikuli_jar%\Lib" ^

      Delete
  40. Hi.mykhailo

    nice article about the integration of sikuli with robot framework.
    i have an issue regarding this-
    i have dowload your calculator test case and try to run it with your guidlines without any changes.
    calc_step1 and calc_step2 running successfully with jybot.bat
    but when i try to run calctest its fail and show me - "TypeError: exists(): 2nd arg can't be coerced to double"

    i am using-
    jre6
    python 2.7
    jython 2.5.2
    robotframework 2.6.3

    Thanks
    Jayanti

    ReplyDelete
    Replies
    1. Hi jayanti and mykhalio,

      did you find the solution to this problem? I am having the same issue. I am using the same compiler and framework as mentioned above and running Sikuli-X-1.0rc3(r905)-win32 for Sikuli.

      Delete
    2. This is the exact message:


      C:\Documents and Settings\Administrator>C:\Sikuli-and-Robot-Framework-Integratio
      n\calctest\jybottest.bat C:\Sikuli-and-Robot-Framework-Integration\calctest\robo
      t_suite\verify_operations.txt
      ==============================================================================
      Verify Operations
      ==============================================================================
      Verify that 2 + 2 = 4 | FAIL |
      TypeError: exists(): 2nd arg can't be coerced to double
      ------------------------------------------------------------------------------
      Verify that 2 + 2 = 5 | FAIL |
      TypeError: exists(): 2nd arg can't be coerced to double
      ------------------------------------------------------------------------------
      Click on non-existent button "Exp" | FAIL |
      TypeError: exists(): 2nd arg can't be coerced to double
      ------------------------------------------------------------------------------
      Verify Operations | FAIL |
      3 critical tests, 0 passed, 3 failed
      3 tests total, 0 passed, 3 failed
      ==============================================================================
      Output: C:\Documents and Settings\Administrator\results\output.xml
      Log: C:\Documents and Settings\Administrator\results\log.html
      Report: C:\Documents and Settings\Administrator\results\report.html

      Delete
  41. Hi Jayanti,

    I would suggest you to download everything from github project mentioned in references section of the blogpost and try to run it in your environment.
    If problem still occur a detailed trace back will be helpful to pinpoint reason of the problem.

    ReplyDelete
    Replies
    1. Hi Jayanti and Mykhailo,

      I meet the similar issue on my Windows 7. And the same script without any modification seems work well on Windows XP.

      I change a little to debug with the overwritten function exists in sikuliwrapper (which is removing any codes related to arg "timeout") as following, then the exception disappear.

      def exists(target):
      addFoundImage(getFilename(target))
      return sikuli_method('exists', target)

      =============================================
      Traceback (most recent call last):

      File "C:\GUI_TestSuites\test\robotframework-2.6.0.jar\Lib\robot\running\keywords$py.class", line 107, in _run
      File "C:\GUI_TestSuites\test\robotframework-2.6.0.jar\Lib\robot\running\handlers$py.class", line 104, in run
      File "C:\GUI_TestSuites\test\robotframework-2.6.0.jar\Lib\robot\running\handlers$py.class", line 116, in _run
      File "C:\GUI_TestSuites\test\robotframework-2.6.0.jar\Lib\robot\running\handlers$py.class", line 127, in _run_with_output_captured_and_signal_monitor
      File "C:\GUI_TestSuites\test\robotframework-2.6.0.jar\Lib\robot\running\handlers$py.class", line 134, in _run_with_signal_monitoring
      File "C:\GUI_TestSuites\test\robotframework-2.6.0.jar\Lib\robot\running\handlers$py.class", line 122, in
      File "C:\GUI_TestSuites\test\XYZLib\CC.py", line 116, in startCC self.goThroughXXX()
      File "C:\GUI_TestSuites\test\XYZLib\XYZ.py", line 39, in goThroughXXX if exists("XXX_banner.png"):
      File "C:\GUI_TestSuites\test\CCLib\sikuliwrapper.py", line 21, in exists return sikuli_method('exists', target, timeout)
      File "C:\GUI_TestSuites\test\CCLib\sikuliwrapper.py", line 16, in sikuli_method return sys.modules['sikuli.Sikuli'].__dict__[name](*args, **kwargs)


      Best regards,
      Jiaqiang

      Delete
    2. Hi Jiaqiang,

      Thank you for your replay and solution you proposed.
      Actually I do not have much time now to play with Sikuli such as most my time I use Robot Framework with Selenium and Expect.

      So I'm sorry for late answers to any comments here. And I appreciate when people post issues that they face and in few hours/days solutions to those problems.

      I definitely need to spend some time to review and update the solutions I described in this post using latest versions of Robot Framework and Sikuli. Also I plan to port these solution on Windows 7 and Mac OS Lion right after I get some fresh air with my current accomplishments.

      Best regards,
      Mykhailo

      Delete
  42. Hi, Mykhailo,

    while trying to launch script in Sikuli IDE I've got the error message:

    [error] Stopped
    [error] An error occurs at line 72
    [error] Error message: Traceback (most recent call last):
    File "C:\Users\TARAS~1.TYM\AppData\Local\Temp\sikuli-tmp8597804719600341477.py", line 72, in
    calc.runTest()
    File "C:\Users\TARAS~1.TYM\AppData\Local\Temp\sikuli-tmp8597804719600341477.py", line 67, in runTest
    self.performAction(*actions)
    File "C:\Users\TARAS~1.TYM\AppData\Local\Temp\sikuli-tmp8597804719600341477.py", line 42, in performAction
    click(Pattern("2.png").similar(0.80)%(args[0],) )
    TypeError: unsupported operand type(s) for %: 'org.sikuli.script.Pattern' and 'tuple'

    Is it a problem with "%" sign in script?

    Thanks,
    Pol

    ReplyDelete
  43. Hi Pol,

    Actually problem is in wrong usage of Python's % operator.
    You will get same error when perform following commands in Python's interpreter:

    >>> class A(object):
    ... pass
    ...
    >>> a = A()
    >>> a % (1,)
    TypeError: unsupported operand type(s) for %: 'A' and 'tuple'

    So problem in your syntax and not in Sikuli IDE.
    What do you expect to do with this line "click(Pattern("2.png").similar(0.80)%(args[0],) )"?

    ReplyDelete
  44. "...What do you expect to do with this line "click(Pattern("2.png").similar(0.80)%(args[0],) )"? ..."

    - that is seems strange to me as well...
    But that expression is in your code...
    click( "btn%s.png" % (args[0],) )
    click( "btn%s.png" % (action,) )
    click( "btn%s.png" % (args[2],) )

    pol

    ReplyDelete
  45. Pol,

    In my case % is used as string formatting operator, so values from tuples replace corresponding %s placeholders in strings.

    In your case first parameter is not string but object of type org.sikuli.script.Pattern. That's why you get this exceptions.

    For more details about string formatting with % operator refer Python's documentation: http://docs.python.org/library/stdtypes.html#string-formatting.

    To avoid exceptions you can try to use either:
    click(Pattern("%s.png" % (args[0],) ).similar(0.80))
    in case you need to click on image with name passed in args[0]

    or:
    click(Pattern("2.png").similar(0.80))
    in case you need to click on image with name "2.png"

    ReplyDelete
  46. Oh, thank you!
    That was confusing me.
    Sorry for such stupid mistake, I should really read more manuals!

    Pol

    ReplyDelete
  47. Ended up tweaking the batch file to this :

    @echo off

    set sikuli_jar=C:\Program Files\Sikuli X\sikuli-script.jar

    java -cp "robotframework-2.6.3.jar;%sikuli_jar%" ^
    -Dpython.path="robotframework-2.6.3.jar\Lib;%sikuli_jar%\Lib" ^
    org.robotframework.RobotFramework ^
    --pythonpath=calc.sikuli ^
    --outputdir=results ^
    --loglevel=TRACE ^
    %*

    But great, great work. No way I'd have made it into this topic without your help. Massive respect and tech thumbs up.

    ReplyDelete
  48. Awesome! Thank you very much for posting this.

    ReplyDelete
  49. Hi Mykhailo
    Great tutorial.
    Please could you gimme some help: the test case's names aren't being recognized, even after I changed it to the exact name of the functions. Do you have some idea why is this happening? I'm using last Sikuli X 1.0rc3.
    Thanks in advance.

    jybottest.bat verify_operations.txt
    [ ERROR ] Error in file '...sikuli\verify_operations.txt' in table 'Settings': Importing test library 'calc.Calculator' failed:
    ImportError: No module named sikuli #(FIRST ERROR)

    PYTHONPATH: [u'...sikuli\\calc.sikuli', 'C:\\Python27\\Lib\\site-packages', 'C:\\Python27\\Lib\\site-packages\\robot\\librar
    ies', 'C:\\Program Files\\Sikuli X\\sikuli-script.jar\\Lib', 'C:\\jython2.5.2\\Lib', '__classpath__', '__pyclasspath__/', 'C:\\jython2.5.2\\
    Lib\\site-packages', '.']
    CLASSPATH: C:\jython2.5.2\jython.jar;C:\Program Files\Sikuli X\sikuli-script.jar
    Traceback (most recent call last):
    File "C:\Python27\Lib\site-packages\robot\utils\importing.py", line 107, in _dotted_import
    __import__(name)
    File "...\sikuli\calc.sikuli\calc.py", line 2, in
    from sikuli.Sikuli import *
    ==============================================================================
    Verify Operations
    ==============================================================================
    Verify that 2 + 2 = 4 | FAIL |
    No keyword with name 'startApp' found.
    ------------------------------------------------------------------------------
    Verify that 2 + 2 = 5 | FAIL |
    No keyword with name 'startApp' found.
    ------------------------------------------------------------------------------
    Verify Operations | FAIL |
    2 critical tests, 0 passed, 2 failed
    2 tests total, 0 passed, 2 failed
    ==============================================================================

    ReplyDelete
  50. Hi Mykhailo.
    Congratulations for the tutorial.
    I hope you can help me with an error I'm having running the test case on robot framework: I'm using Sikuli X 1.0rc3. I followed all previous steps configuration, but when I execute "jybottest.bat verify_operations.txt" I'm receiving the following errors:

    [ ERROR ] Error in file 'C:\Users\user\sikuli\verify_operations.txt' in table 'Settings': Importing test library 'calc.Calculator' failed:
    ImportError: No module named sikuli
    PYTHONPATH: [u'C:\\Users\\user\\sikuli\\calc.sikuli', 'C:\\Python27\\Lib\\site-packages', 'C:\\Python27\\Lib\\site-packages\\robot\\librar
    ies', 'C:\\Program Files\\Sikuli X\\sikuli-script.jar\\Lib', 'C:\\jython2.5.2\\Lib', '__classpath__', '__pyclasspath__/', 'C:\\jython2.5.2\\
    Lib\\site-packages', '.']
    CLASSPATH: C:\jython2.5.2\jython.jar;C:\Program Files\Sikuli X\sikuli-script.jar
    Traceback (most recent call last):
    File "C:\Python27\Lib\site-packages\robot\utils\importing.py", line 107, in _dotted_import
    __import__(name)
    File "C:\Users\user\sikuli\calc.sikuli\calc.py", line 2, in
    from sikuli.Sikuli import *
    ==============================================================================
    Verify Operations
    ==============================================================================
    Verify that 2 + 2 = 4 | FAIL |
    No keyword with name 'startApp' found.
    ------------------------------------------------------------------------------
    Verify that 2 + 2 = 5 | FAIL |
    No keyword with name 'startApp' found.
    ------------------------------------------------------------------------------
    Verify Operations | FAIL |
    2 critical tests, 0 passed, 2 failed
    2 tests total, 0 passed, 2 failed
    ==============================================================================

    You or someone have any idea on why it cant find sikuli module? I think it is the main error that is causing the next errors on finding test keywords.
    Thanks in advance.

    ReplyDelete
  51. I am not able to get this to using jython. Using the java method it does work. Any ideas as to why this will not work using jython?

    Java start method:
    set sikuli_jar=C:\Program Files\Sikuli X\sikuli-script.jar
    start call java -cp "E:\Workspace\Trunk\jar\robotframework-2.6.0.jar;
    %sikuli_jar%" ^
    -Dpython.path="%sikuli_jar%/Lib" ^
    org.robotframework.RobotFramework ^
    --pythonpath "E:\Workspace\Trunk\python" ^
    --outputdir "e:\reports" ^
    --loglevel=TRACE ^
    E:\Workspace\trunk\LM\Web\SuiteSingle\CodeTesting.txt
    %*

    jython batch file start:
    set sikuli_jar=C:\Program Files\Sikuli X\sikuli-script.jar
    set rf_jar=E:\Workspace\Trunk\jar\robotframework-2.6.0.jar
    set CLASSPATH="%sikuli_jar%%"
    set JYTHONPATH=%sikuli_jar%/Lib
    c:
    cd c:\
    start call jybot ^
    --outputdir e:\Reports ^
    --pythonpath "E:\Workspace\Trunk\python\Sikuli" ^
    E:\Workspace\trunk\LM\Web\SuiteSingle\CodeTesting.txt

    error recieved:
    error importing site
    Traceback (most recent call last):
    File "C:\Program Files\Sikuli X\sikuli-script.jar\Lib\site.py", line
    62, in
    File "C:\Program Files\Sikuli X\sikuli-script.jar\Lib\os.py", line
    904, in
    AttributeError: '

    ReplyDelete
    Replies
    1. Hi Greg,

      It seems this issue is related to a specific version of Jython.
      Please refer the link below to get more info:
      https://bugs.launchpad.net/sikuli/+bug/782818

      I would suggest you to try your script on other version of Jython.
      In case it won't work - please reply here with info about specific versions of Java, Jython, Sikuli you used.

      --Mykhailo

      Delete
    2. I installed Jython 2.5.1 and I get the following error. I am using Sikuli X-1.0rc2 and Java 1.6.0_29.


      ==============================================================================
      Sikuli & CodeTesting
      ==============================================================================
      [ ERROR ] Error in file 'E:\Workspace\trunk\LM\Web\SuiteSingle\CodeTesting.txt'
      in table 'Settings': Importing test library 'SikuliLibrary' failed: ImportError:
      No module named SikuliLibrary
      PYTHONPATH: ['C:\\Python27\\Lib\\site-packages', 'C:\\Python27\\Lib\\site-packag
      es\\robot\\libraries', 'C:\\Program Files\\Sikuli X\\sikuli-script.jar\\Lib', 'C
      :\\jython2.5.1\\Lib', '__classpath__', '__pyclasspath__/', 'C:\\jython2.5.1\\Lib
      \\site-packages', '.']
      CLASSPATH: C:\jython2.5.1\jython.jar;C:\Program Files\Sikuli X\sikuli-script.jar

      Traceback (most recent call last):
      File "C:\Python27\Lib\site-packages\robot\utils\importing.py", line 86, in _no
      n_dotted_import
      module = __import__(name)
      Sikuli & CodeTesting.CodeTesting
      ==============================================================================
      Verify LMWeb | FAIL |
      No keyword with name 'ShowActionsOn' found.
      ------------------------------------------------------------------------------
      Sikuli & CodeTesting.CodeTesting | FAIL |
      1 critical test, 0 passed, 1 failed
      1 test total, 0 passed, 1 failed
      ==============================================================================
      Sikuli & CodeTesting | FAIL |
      1 critical test, 0 passed, 1 failed
      1 test total, 0 passed, 1 failed
      ==============================================================================
      Output: e:\Reports\output.xml
      Log: e:\Reports\log.html
      Report: e:\Reports\report.html

      C:\>

      Delete
    3. It seems your previous issue disappeared with Jython 2.5.1 installed and now you are moved further to ImportError.

      From the error message it can be seen that Robot could not find SikuliLibrary. Make sure that path to its installation is present PYTHONPATH.

      Delete
  52. Adding the following did the trick.

    set python=E:\Workspace\Trunk\python
    set PYTHONPATH=%python%

    I guess Jython 2.5.2 was the issue. Thanks for the help.

    ReplyDelete
  53. Well now it runs using Jython but I have another set of issues.

    I get this error:

    IOError: [Errno 13] EACCES: '/Workspace/Trunk/images/Screenshot/2012-02-27_10-33-12.png'

    ZERO issues running with java. It acts like it is not even matching the images because it fails on the 1st test. Any ideas as to this error using jybot?

    ReplyDelete
  54. I figured this out and here is the solution.

    Java - Folder paths
    screenshot folder used was "/Workspace/Trunk/images/Screenshot/"
    image folder used was "/Workspace/Trunk/images/LM Web/Login/"

    Jython - Folder paths
    screenshot folder used was "E:/Workspace/Trunk/images/Screenshot/"
    image folder used was "E:/Workspace/Trunk/images/LM Web/Login/"

    Basically I needed the full path in jython. Using the full path in java did not work.

    ReplyDelete
  55. Hi am anji,,,
    I have installed sikuli but when am trying to capture picture the tool was closed,,,can any one plz,,,tell me the solution

    thanks in advance,,,

    ReplyDelete
  56. I FINALLY got my x86 to work by adding the following to the jybottest.bat file:
    set JAVA_HOME="C:\Program Files (x86)\Java\jre6\

    I had set it on my computer using the system variables setting but jython just wouldn't take it.

    ReplyDelete
  57. using this method, is there any way to show/save the std out generated by sikuli runtime for debug purposes? sometimes i get false positives when i expect a test to fail but i can't see the output of sikuli.

    thanks!

    ReplyDelete
    Replies
    1. I think so, but you'd get a better answer asking this on the Robot Framework user group to which this blog is about regarding Sikuli.

      http://groups.google.com/group/robotframework-users

      Delete
    2. BTW, I monitor robotframework-users group and try to answer all the discussions where this blog post is mentioned.

      Delete
  58. I just tried on my Windows 7 and it works.
    Thanks for the great example.
    I'd like to try on an Android device. Can you give an example.
    Thank you much!

    ReplyDelete
    Replies
    1. should work same way, but you need to run Android emulator on the machine running Sikuli. It won't work natively on Android device. If you want native Android device support, check out Experitest's SeeTest tool, which is commercial tool, not free.

      Note that for Android example, you run emulator, and capture screenshots of the UI within emulator you want to manipulate then use Sikuli code/script to perform those.

      you would have to separately start up emulator before running Sikuli tests or have the tests start up the emulator as part of the test setup.

      Delete
  59. hello,
    Using Sikuli X-1.0rc2 (r905) on win7, downloaded your sample from github, when open calc_step1, got error below:

    java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.sikuli.ide.SikuliIDE$MenuAction.actionPerformed(SikuliIDE.java:1065)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.AbstractButton.doClick(Unknown Source)
    at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
    at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Sour

    ce)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$000(Unknown Source)
    at java.awt.EventQueue$1.run(Unknown Source)
    at java.awt.EventQueue$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknow

    n Source)
    at java.awt.EventQueue$2.run(Unknown Source)
    at java.awt.EventQueue$2.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    Caused by: java.lang.NullPointerException
    at org.sikuli.ide.ImageButton.createFromString(ImageButton.java:241)
    at org.sikuli.ide.SikuliPane.replaceWithImage(SikuliPane.java:617)
    at org.sikuli.ide.SikuliPane.parseLine(SikuliPane.java:568)
    at org.sikuli.ide.SikuliPane.parseRange(SikuliPane.java:528)
    at org.sikuli.ide

    .SikuliPane.parse(SikuliPane.java:543)
    at org.sikuli.ide.SikuliPane.parse(SikuliPane.java:546)
    at org.sikuli.ide.SikuliPane.read(SikuliPane.java:427)
    at org.sikuli.ide.SikuliPane.loadFile(SikuliPane.java:372)
    at org.sikuli.ide.SikuliPane.loadFile(SikuliPane.java:383)
    at org.sikuli.ide.SikuliIDE$FileAction.doLoad(SikuliIDE.java:1411)
    ... 43 more

    ReplyDelete
    Replies
    1. it seems you have some issues with Sikuli IDE installation. Please make sure you followed all the installation steps from the official website.

      Delete
  60. Getting following error:
    D:\>java -jar "c:\program files\sikuli x\sikuli-script.jar" 123.sikuli
    [error] Can't run this Sikuli script: 123.sikuli
    Traceback (most recent call last):
    File "", line 1, in
    File "C:\Program Files\Sikuli X\sikuli-script.jar\Lib\sikuli\__init__.py", lin
    e 3, in
    File "C:\Program Files\Sikuli X\sikuli-script.jar\Lib\sikuli\Sikuli.py", line
    22, in
    java.lang.UnsatisfiedLinkError: C:\Documents and Settings\Administrator\Local Se
    ttings\Temp\tmplib\VisionProxy.dll: Can't find dependent libraries
    com.wapmx.nativeutils.jniloader.NativeLoader.loadLibrary(NativeLoader
    .java:44)
    org.python.core.packagecache.SysPackageManager.findClass(SysPackageMa
    nager.java:133)
    at org.python.core.packagecache.PackageManager.findClass(PackageManager.
    java:28)
    at org.python.core.packagecache.SysPackageManager.findClass(SysPackageMa
    nager.java:122)
    at org.python.core.PyJavaPackage.__findattr_ex__(PyJavaPackage.java:137)

    at org.python.core.PyObject.__findattr__(PyObject.java:863)
    at org.python.core.imp.import_name(imp.java:849)
    at org.python.core.imp.importName(imp.java:884)
    at org.python.core.ImportFunction.__call__(__builtin__.java:1220)
    at org.python.core.PyObject.__call__(PyObject.java:357)
    at org.python.core.__builtin__.__import__(__builtin__.java:1173)
    at org.python.core.imp.importFromAs(imp.java:978)
    at org.python.core.imp.importFrom(imp.java:954)
    at sikuli.Sikuli$py.f$0(C:\Program Files\Sikuli X\sikuli-script.jar\Lib\
    sikuli\Sikuli.py:211)
    at sikuli.Sikuli$py.call_function(C:\Program Files\Sikuli X\sikuli-scrip
    t.jar\Lib\sikuli\Sikuli.py)
    at org.python.core.PyTableCode.call(PyTableCode.java:165)
    at org.python.core.PyCode.call(PyCode.java:18)
    at org.python.core.imp.createFromCode(imp.java:386)
    at org.python.core.util.importer.importer_load_module(importer.java:109)

    at org.python.modules.zipimport.zipimporter.zipimporter_load_module(zipi
    mporter.java:161)
    at org.python.modules.zipimport.zipimporter$zipimporter_load_module_expo
    ser.__call__(Unknown Source)
    at org.python.core.PyBuiltinMethodNarrow.__call__(PyBuiltinMethodNarrow.
    java:47)
    at org.python.core.imp.loadFromLoader(imp.java:513)
    at org.python.core.imp.find_module(imp.java:467)
    at org.python.core.PyModule.impAttr(PyModule.java:100)
    at org.python.core.imp.import_next(imp.java:715)
    at org.python.core.imp.import_name(imp.java:824)
    at org.python.core.imp.importName(imp.java:884)
    at org.python.core.ImportFunction.__call__(__builtin__.java:1220)
    at org.python.core.PyObject.__call__(PyObject.java:357)
    at org.python.core.__builtin__.__import__(__builtin__.java:1173)
    at org.python.core.imp.importAll(imp.java:998)
    at sikuli$py.f$0(C:\Program Files\Sikuli X\sikuli-script.jar\Lib\sikuli\
    __init__.py:3)
    at sikuli$py.call_function(C:\Program Files\Sikuli X\sikuli-script.jar\L
    ib\sikuli\__init__.py)
    at org.python.core.PyTableCode.call(PyTableCode.java:165)
    at org.python.core.PyCode.call(PyCode.java:18)
    at org.python.core.imp.createFromCode(imp.java:386)
    at org.python.core.util.importer.importer_load_module(importer.java:109)

    at org.python.modules.zipimport.zipimporter.zipimporter_load_module(zipi
    mporter.java:161)
    at org.python.modules.zipimport.zipimporter$zipimporter_load_module_expo
    ser.__call__(Unknown Source)
    at org.python.core.PyBuiltinMethodNarrow.__call__(PyBuiltinMethodNarrow.
    java:47)
    java.lang.UnsatisfiedLinkError: java.lang.UnsatisfiedLinkError: C:\Documents and
    Settings\Administrator\Local Settings\Temp\tmplib\VisionProxy.dll: Can't find d
    ependent libraries

    ReplyDelete
  61. Hi Mykhailo!
    I am following your example to perform simple actions over eclipse IDE. Here, on using mouse actions, I am using image comparison provided by sikuli.
    However, on image comparison, in some cases, following error occurs:

    FindFailed: can not find Screencapture21.png on the screen.
    ...
    FindFailed: Line 322, in file C:\Python27\lib\site-packages\robot\runner.py at org.sikuli.script.Region.handleFindFailed(Region.java:420)
    at org.sikuli.script.Region.wait(Region.java:511)

    Both the images are same as appeared from these logs and comparing these from sikuli, both of them are matching with the target image.
    I then specified minimum image comparison to be 80% by specifying Settings.MinSimilarity = 0.80 in the test script, but it yielded nothing.

    In sikuli IDE image comparison match window, the same image is getting matched successfully till 100%.
    Is there any tweak to get this image comparison working?

    ReplyDelete
  62. Hi, Mykhailo

    I got a problem that when i used jybottest.bat to run and got the following error.
    C:\work>jybottest.bat robot_suite\verify_operations.txt
    Traceback (most recent call last):
    File "C:\Python27\Lib\site-packages\robot\run.py", line 322, in
    import pythonpathsetter # running robot/run.py as a script
    File "C:\Python27\Lib\site-packages\robot\pythonpathsetter.py", line 17, in
    import os
    File "C:\Program Files\Sikuli X\sikuli-script.jar\Lib\os.py", line 118, in
    ImportError: no os specific module found
    It seems nobody got the same issue when use jybottest.bat. But i do the exactly steps you did .
    calc.sikuli→ calc.py
    robot_suite→ verify_operations.txt
    no change to jybottest.bat
    sikuli-x-1.0rc3 in C:\Program Files\Sikuli X
    Robot framework 2.7.1 , python 2.7.2 , jython 2.5.1 .
    I really don't know what's wrong .Hope for your help!

    And another thing , is there possible to use keywords from sikuli library and keywords from AutoItLibrary to be a new library? And the new library can import to a test case to test windows application while it's written by Delphi?
    Regrads,
    xingxing

    ReplyDelete
  63. Hi, Mykhailo

    I got a problem that when i used
    jybottest.bat to run and got the following
    error.
    C:\work>jybottest.bat
    robot_suite\verify_operations.txt
    Traceback (most recent call last):
    File "C:\Python27\Lib\site-
    packages\robot\run.py", line 322, in
    import pythonpathsetter # running
    robot/run.py as a script
    File "C:\Python27\Lib\site-
    packages\robot\pythonpathsetter.py", line
    17, in
    import os
    File "C:\Program Files\Sikuli X\sikuli-
    script.jar\Lib\os.py", line 118, in
    ImportError: no os specific module found
    It seems nobody got the same issue when
    use jybottest.bat. But i do the exactly
    steps you did .
    calc.sikuli→ calc.py
    robot_suite→ verify_operations.txt
    no change to jybottest.bat
    sikuli-x-1.0rc3 in C:\Program Files\Sikuli X
    Robot framework 2.7.1 , python 2.7.2 ,
    jython 2.5.1 .
    I really don't know what's wrong .Hope for
    your help!

    And another thing , is there possible to
    use keywords from sikuli library and
    keywords from AutoItLibrary to be a new
    library? And the new library can import to a
    test case to test windows application while
    it's written by Delphi?
    Regrads,
    xingxing

    ReplyDelete
  64. I'm getting the "TypeError: exists(): 2nd arg can't be coerced to double" error when running my script.

    Anyone solve this problem yet?

    I'm on Win7 32 bit, using Robot Framework 2.7.1, and Sikuli RC3

    ReplyDelete
  65. I resolved the "2nd arg can't be coerced to double" error by reverting back to using RobotFramework 2.6.0 and Sikuli RC2. Anyone able to get this to work with RF2.7.1 and Sikuli RC3?

    ReplyDelete
    Replies
    1. Look into changes in a pull request to the github project:
      https://github.com/imikemo/Sikuli-and-Robot-Framework-Integration/pull/1

      I'm not sure whether this is the same issue, at least error message seems the same.

      Delete
    2. The pull request on github solved the "2nd arg can't be coerced to double" error for me. I change timeout=None to timeout=0 and cast the timeout as float.

      I'm now running this successfully on Win7 32-bit, Sikuli RC3, and Robot Framework 2.7.1, using Jenkins.

      Time to build out some tests!

      Thanks for the tip!

      Delete
  66. Hi Mykhailo,

    Thanks for the guide, really interesting, I´ve been following the steps, and when running the test, after :

    C:\work\> jybottest.bat robot_suite\verify_operations.txt

    It returns unable to find the path, I´m blocked here, could you please give me some tips.

    Thank you

    ReplyDelete
    Replies
    1. What path it can't find: path to jybottest.bat or path to the test case? If former - then make sure jybottest.bat is in PATH environment variable, if latter - then either specify absolute path to the test case or path that is relative to C:\work\

      Delete
  67. Hi there,
    Could someone help me ?

    I was using Sikuli RC2 + Python 2.7 + Ride 0.44, with no problems however I´ve updated my Sikuli for RC3 and right now I am getting the following error message:

    "Traceback (most recent call last):
    File "C:\Python27\lib\site-packages\robot\run.py", line 322, in
    import pythonpathsetter # running robot/run.py as a script
    File "C:\Python27\Lib\site-packages\robot\pythonpathsetter.py", line 17, in
    import os
    File "C:\Program Files\Sikuli X\sikuli-script.jar\Lib\os.py", line 118, in
    ImportError: no os specific module found"


    I am wondering it´s the Python Path is not set,perhaps I do not know how to do it, I´ve attempted some ways to get it working on, no success.

    Regards,
    Thiago F. Peçanha

    ReplyDelete
  68. Hi,
    I have win7, 64 bit machine.
    If I run the only sikuli script through command prompt, it runs successfully(Thanks to jre 32 bit calsspath) :).
    But while running the above script with robotframework-2.7.3.jar it gives me following error.:(

    E:\Sikuli-and-Robot-Framework-Integration\A.sikuli>robottest.bat e:\Sikuli-and-R
    obot-Framework-Integration\A.sikuli
    ==============================================================================
    A.sikuli
    ==============================================================================
    A.sikuli.Robot Suite
    ==============================================================================
    [ ERROR ] Error in file 'e:\Sikuli-and-Robot-Framework-Integration\A.sikuli\robo
    t_suite\verify_operations.txt' in table 'Settings': Importing test library 'A.Ca
    lculator' failed: UnsatisfiedLinkError: C:\Users\a\AppData\Local\Temp\tmplib\
    VisionProxy.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform
    java.lang.UnsatisfiedLinkError:
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(Unknown Source)
    .........
    at robot.jarrunner$py.call_function(/Users/jmalinen/Documents/workspace/
    robot/tmp-jar-dir/Lib/robot/jarrunner.py)
    at org.robotframework.RobotFramework.run(RobotFramework.java:62)
    at org.robotframework.RobotFramework.main(RobotFramework.java:37)
    PYTHONPATH:
    E:\Sikuli-and-Robot-Framework-Integration\A.sikuli\CalcLib
    E:\Sikuli-and-Robot-Framework-Integration\A.sikuli\robotframework-2.7.3.jar\Li
    b\robot\libraries
    E:\Sikuli-and-Robot-Framework-Integration\A.sikuli\robotframework-2.7.3.jar\Li
    b
    D:\Sikuli-X-1.0rc3 (r905)-win32\Sikuli-IDE\sikuli-script.jar\Lib
    E:\Sikuli-and-Robot-Framework-Integration\A.sikuli\Lib
    __classpath__
    __pyclasspath__/
    .
    E:\Sikuli-and-Robot-Framework-Integration\A.sikuli
    CLASSPATH:
    robotframework-2.7.3.jar
    D:\Sikuli-X-1.0rc3 (r905)-win32\Sikuli-IDE\sikuli-script.jar
    A.sikuli.Robot Suite.Verify Operations
    ==============================================================================
    | FAIL |
    Test case name is required.
    ------------------------------------------------------------------------------
    A.sikuli.Robot Suite.Verify Operations | FAIL |
    1 critical test, 0 passed, 1 failed
    1 test total, 0 passed, 1 failed
    ==============================================================================
    A.sikuli.Robot Suite | FAIL |
    1 critical test, 0 passed, 1 failed
    1 test total, 0 passed, 1 failed
    ==============================================================================
    A.sikuli | FAIL |
    1 critical test, 0 passed, 1 failed
    1 test total, 0 passed, 1 failed
    ==============================================================================
    Output: E:\Sikuli-and-Robot-Framework-Integration\A.sikuli\results1\output.xml
    Log: E:\Sikuli-and-Robot-Framework-Integration\A.sikuli\results1\log.html
    Report: E:\Sikuli-and-Robot-Framework-Integration\A.sikuli\results1\report.html


    E:\Sikuli-and-Robot-Framework-Integration\A.sikuli>

    Any help would be appriciated.
    Thanks.

    ReplyDelete
    Replies
    1. Install 32bit Java JRE.

      Delete
  69. Hi I run in WIN7 32bit.

    from sikuli.Sikuli import * <= ImportError

    why??

    ReplyDelete
    Replies
    1. Could you post the traceback here? It is hard to say what the exact reason on you case.
      ImportError means that sikuli module could not beed found and therefore imported.

      Delete
  70. main.py
    import clear_dns
    sikuli.Sikuli import *
    class main:
    def core_1(self, OS):
    flag = clear_dns.cleardns(1)

    clear_dns.py
    def clear_dns(OS)
    if OS == 1:
    print("Good")

    I use RIDE to execute core_1(1),but i found error.

    [ ERROR ] Error in file 'F:\Robot\Belkin\Core.txt' in table 'Settings': Importing test library 'F:\Robot\Belkin\lib\main.py' failed: ImportError: No module named sikuli
    Traceback (most recent call last):
    File "F:\Robot\Belkin\lib\main.py", line 7, in
    from sikuli.Sikuli import *
    PYTHONPATH:
    C:\Python27\Lib\site-packages\robot\libraries
    C:\Python27\Lib\site-packages
    C:\jython2.5.3b1\Lib
    __classpath__
    __pyclasspath__/
    C:\jython2.5.3b1\Lib\site-packages
    .
    F:\Robot\Belkin
    CLASSPATH:
    C:\jython2.5.3b1\jython.jar

    ReplyDelete
    Replies
    1. I try from command line.set classpath=C:\sikuli-script.jar
      the issues still there.

      CLASSPATH doesn't display from RIDE, but commandline has.

      Delete
    2. Try to run your script using either robottest.bat or jybottest.bat (that are described in this blog post) from command line. From RIDE there is possibility to set custom script to run tests - try to set robottest.bat or jybottest.bat.

      Delete
    3. Thanks~you are right! I use .bat from command to running, now it is work fine.

      But i found one WARN message, can you help me again?

      I have post issue to this page.BUG ID is 1013
      http://code.google.com/p/robotframework-ride/issues/list

      Delete
    4. Hi @藍成浩,

      Could you import "sikuli.Sikuli import *" in main.py and then you called functions of main.py in RIDE?

      We can discuss on this page
      http://code.google.com/p/robotframework-ride/issues/detail?id=1181&thanks=1181&ts=1357212799

      Delete
    5. It seems that RIDE experiences issues when trying to load your library. You can look inside RIDE log for more details.

      According to following doc libraries written on Java could not be loaded directly into RIDE for keyword comletion:
      https://github.com/robotframework/RIDE/wiki/Keyword-Completion#wiki-libraries-not-available-locally-or-written-in-java

      But you still able to use and see them when generate specification and feed it instead to RIDE as it described in the document below:
      https://github.com/robotframework/RIDE/wiki/Keyword-Completion#wiki-using-library-specs

      Have fun!

      Delete
    6. Hi Mykhailo Moroz,

      Do you run Calculator.py on Robot Framework RIDE? Could you give me more detail to run on RIDE?

      Thanks,

      Delete
    7. Robot Framework IDE can only be used for editing test cases. When you run any test case from it - it actually run external command (pybot by default, or any you have set) and pass list of arguments to it.
      Additionally RIDE grabs the output of that external command and print it to you in its own window and setup few listeners.

      So once you are able to run your test case from commadn line - you will be able to do that from RIDE. The only thing you need to do is to set your own "Run Configuration" for RIDE. In other words say what external command RIDE should run instead of pybot.

      Delete
    8. Hi Mykhailo Moroz,

      Ok, It's working. Thank you so much.

      Best regards,

      Delete
  71. This is a great tutorial.. Thank you very much.

    I have a question for you. Is it possible to use robotframework work with monkeyrunner.jar directly.
    I asked the question in stackoverflow

    http://stackoverflow.com/questions/12693744/monkeyrunner-with-robotframework

    I followed your steps, and just included monkeyrunner.jar, but it is giving error

    NoClassDefFoundError: Could not initialize class com.android.monkeyrunner.MonkeyDevice
    java.lang.NoClassDefFoundError:

    ReplyDelete
    Replies
    1. Hi Durairaj,

      I am not sure about monkey runner but when I tried to run both Sikuli and Robot jars I faced an issue. Both these jars had Jython insides and you will run just one of them.
      Try to unzip your jars and see where exactly no found classes are located and add them into PYTHONPATH using: -Dpython.path e.g. -Dpython.path="%sikuli_jar%/Lib"
      https://github.com/imikemo/Sikuli-and-Robot-Framework-Integration/blob/master/calctest/robottest.bat

      NB: robot.jar should be first in my case, it just did not work when sikuli.jar was first :)

      Let me know whether my hint helped you.

      Thanks,
      Mykhailo

      Delete
  72. Hi Mykhailo,
    Thank you. After posting, I found out the issue. Thank you very much.

    ReplyDelete
  73. This comment has been removed by a blog administrator.

    ReplyDelete
  74. Hi Mykh,

    I am getting below stack trace when i try running sikuli using jybottest.bat.

    OS-Windows7
    softwares
    Python 2.7
    Jython 2.5.2
    Robotframework 2.7.a2
    Sikuli-X-1.0rc3 (r905

    Sytem Path settings
    C:\Program Files\Sikuli X\libs;C:\Program Files\Java\jre6\\bin;C:\Python27\Scripts;C:\jython_installer-2.5.2\bin;.;

    Jybottest.bat snippet:

    @echo off

    set sikuli_jar=C:\Program Files\Sikuli X\sikuli-script.jar

    set CLASSPATH=%sikuli_jar%
    set JYTHONPATH=%sikuli_jar%/Lib

    jybot --pythonpath=Discovery_Portal17.sikuli --outputdir=results --loglevel=TRACE %*





    C:\work>jybottest.bat robot_suite\Discovery_Portal17.txt
    [ ERROR ] Error in file 'C:\work\robot_suite\Discovery_Portal17.txt' in table 'Settings': Importing test library 'Discovery_Portal17.SimpleTest' failed: ImportError: No module named Discovery_Portal17
    Traceback (most recent call last):
    None
    PYTHONPATH:
    C:\work\Discovery_Portal17.sikuli
    C:\Python27\Lib\site-packages\robot\libraries
    C:\Python27\Lib\site-packages
    C:\Program Files\Sikuli X\sikuli-script.jar\Lib
    C:\jython_installer-2.5.2\Lib
    __classpath__
    __pyclasspath__/
    C:\jython_installer-2.5.2\Lib\site-packages
    .
    C:\work
    CLASSPATH:
    C:\jython_installer-2.5.2\jython.jar
    C:\Program Files\Sikuli X\sikuli-script.jar
    ==============================================================================
    Discovery Portal17
    ==============================================================================
    Discovery openbrowser | FAIL |
    No keyword with name 'Openbrowser' found.
    ------------------------------------------------------------------------------
    Discovery login | FAIL |
    No keyword with name 'Portallogin' found.
    ------------------------------------------------------------------------------
    Discovery Home | FAIL |
    No keyword with name 'Discoveryhome' found.
    ------------------------------------------------------------------------------
    Discovery Services | FAIL |
    No keyword with name 'Registryservices' found.
    ------------------------------------------------------------------------------
    Discovery apinventory | FAIL |
    No keyword with name 'appinventory' found.
    ------------------------------------------------------------------------------
    Discovery DataWareHouse | FAIL |
    No keyword with name 'datawarehouse' found.
    ------------------------------------------------------------------------------
    Discovery OOAdiscoverysites | FAIL |
    No keyword with name 'OOASharepointsites' found.
    ------------------------------------------------------------------------------
    Discovery Portal17 | FAIL |
    7 critical tests, 0 passed, 7 failed
    7 tests total, 0 passed, 7 failed
    ==============================================================================
    Output: C:\work\results\output.xml
    Log: C:\work\results\log.html
    Report: C:\work\results\report.html

    Please provide your valuable suggestions.

    Thanks,
    Jacob

    ReplyDelete
  75. Hi Mykhailo,

    Your tutorial is great. It is helping me lot in automating my scripts. I had some doubts in running script through robottest.bat .. whenever i run my script through robottest.bat, i am getting below error message.

    C:\Sanity_Automation\work_project>robottest.bat robot_suite\verify_operations.txt
    Exception in thread "main" java.lang.NoClassDefFoundError: org/robotframework/RobotFramework
    Caused by: java.lang.ClassNotFoundException: org.robotframework.RobotFramework
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    Could not find the main class: org.robotframework.RobotFramework. Program will exit.

    and one more doubt is that, can i import TCl\tk using your your script?I tried myself. but i am caught up not found error

    C:\Sanity_Automation\work_project>jybottest.bat robot_suite\verify_operations.txt
    [ ERROR ] Error in file 'C:\Sanity_Automation\work_project\robot_suite\verify_operations.txt' in table 'Settings': Importing test library 'n2x.n2xSession' failed: ImportError: No module named _tkinter
    PYTHONPATH: [u'C:\\Sanity_Automation\\work_project\\n2x.sikuli', 'C:\\Sanity_Automation\\Python272\\Lib\\site-packages', 'C:\\Sanity_Automation\\Python272\\Lib\\site-packages\\robot\\libraries', 'C:\\Sanity_Automation\\Sikuli_X\\sikuli-script.jar\\Lib', 'C:\\Sanity_Automation\\Jython251\\Lib', '__classpath__', '__pycla
    sspath__/', 'C:\\Sanity_Automation\\Jython251\\Lib\\site-packages', '.']
    CLASSPATH: C:\Sanity_Automation\Jython251\jython.jar;C:\Sanity_Automation\Sikuli_X\sikuli-script.jar Traceback (most recent call last):
    File "C:\Sanity_Automation\Python272\Lib\site-packages\robot\utils\importing.py", line 107, in _dotted_import
    __import__(name)
    File "C:\Sanity_Automation\work_project\n2x.sikuli\n2x.py", line 2, in
    import Tkinter
    File "C:\Sanity_Automation\work_project\n2x.sikuli\Tkinter.py", line 39, in
    import _tkinter # If this fails your Python may not be configured for Tk

    If you know, can u help me out with this.

    ReplyDelete
  76. Hi Mykhailo,
    Thanks for this blog. i am able to automate some of the module. I had some doubts regarding robot framework .html result generation.

    1> When i execute 2 test case and in that if 1 test case fails, it stops there only throwing exception. Is there any way to make it to continue and execute second testcase.??

    2> Whenever it(sikuli) detects an objects matching stored template. It focus/blinks 3 times on that before performing action. Is there any way to reduce number of blinks to 1?

    Thanks,
    Yashwanth

    ReplyDelete
  77. Hi Mykhailo,

    Want to thank you for your blog also, it inspired some of the ideas behind my latest project SikuliFramework.

    SikuliFramework is a GUI Automation Framework for Sikuli. The framework provides an object-oriented abstraction on top of Sikuli to assist with interacting GUI elements, such as sets of buttons, checkboxes, radio buttons, windows and dialogue hierarchies for GUI automation and testing.

    Check it out @ https://github.com/smysnk/sikuli-framework

    Thanks,
    Josh

    ReplyDelete
  78. There is a problem on Robot Framework working with the Sikuli Tools (Jython/python).

    If you set up Test suite with Set up and tear Down, once the test step fail on the Set up, it definitely skips all test step to save the test time, but on the test report marked total test step fails,it is confused the tester. I tried to re-coding the Robot Frame work on logger, but it was not able to changed.

    So use keyword step by steps instead of Setup and Tear Down on test Suite


    ReplyDelete
  79. Hi, and thank you very much for the manual.
    I have a problem with Robot logger - I've done what I could, but reports are still same, without screenshots. Please help me!

    In common.py I've changed only this string (my images are in images.sikuli folder):
    cfgImageLibrary = "images.sikuli" # image search directory

    my sikuli code:
    ---------------------------------------------
    from sikuliwrapper import *
    addImagePath(common.cfgImageLibrary)
    import images
    reload(images)
    from images import *
    import regions
    reload(regions)
    from regions import *

    class TestCreateCT(BaseLogger):
    def __init__(self, name):
    self._name = name

    def type_password(self, password="1q2w3eQAZ", retype_password=None):
    if retype_password is None:
    retype_password = password
    click(TypePassword_label)
    ---------------------------------------------

    logger.py common.py and sikuliwrapper.py are in c:/robot/libs

    jybottest is in c:/robot/
    -------------------------------------------------------
    @echo off

    set sikuli_jar=C:\Program Files\Sikuli X\sikuli-script.jar

    set CLASSPATH=%sikuli_jar%
    set JYTHONPATH=%sikuli_jar%/Lib

    jybot --pythonpath=libs/main.sikuli/ ^
    --pythonpath=libs/ ^
    --pythonpath=libs/images.sikuli/ ^
    --pythonpath=libs/regions.sikuli/ ^
    --outputdir=results ^
    --loglevel=TRACE ^
    %*
    -----------------------------------------------------------

    ReplyDelete
    Replies
    1. Hello,

      I would suggest to start from scratch: download code from the github, run it and check whether images are shown.
      If yes - then do modification periodically checking that you still have the images ;).
      If no - then most probably somemthing went wrong with your installations. Re-install and try from scratch.

      Try to analyze log for errors - they are sometimes helpful ;)

      Thank you for your comment.

      Delete
    2. With your files I have an error in sikuliwrapper, but I can't figure out what's wrong:

      21:23:39.917
      TRACE
      Arguments: [ ]

      21:23:39.933
      FAIL
      TypeError: exists(): 2nd arg can't be coerced to double

      21:23:39.933

      DEBUG
      Traceback (most recent call last):
      File "c:\git\calctest\CalcLib\calc.py", line 22, in verifyApp
      if exists("CalcApp.png"):
      File "c:\git\calctest\CalcLib\sikuliwrapper.py", line 21, in exists
      return sikuli_method('exists', target, timeout)
      File "c:\git\calctest\CalcLib\sikuliwrapper.py", line 16, in sikuli_method
      return sys.modules['sikuli.Sikuli'].__dict__[name](*args, **kwargs)

      Delete
    3. I've fixed this error changing
      # overwritten Screen.exists method
      def exists(target, timeout=None):

      with

      # overwritten Screen.exists method
      def exists(target, timeout=1):
      ------------

      but if I change VerifyApp to simple click operation

      def verifyApp(self):
      # check application
      click("CalcApp.png")
      # if exists("CalcApp.png"):
      # self.log.passed("Calculator window appeared")
      # else:
      # self.log.failed("No calculator window")

      there will be no screenshots in report.
      I thought the main point is that I'll have screenshots on every FindFailed operation =( I thought that is sikuliwrapper what for.
      Am I right, that I'll have srceens on FindFailed only if I use construction below?
      if exists("CalcApp.png"):
      print("PASS: Calculator window appeared")
      else:
      print("FAIL: No calculator window")

      Delete
    4. FindFailed is an exception - not operation. In this blogpost I show how to log a screenshot by handling this exception in overwritten Region.click() method.
      In your example click("CalcApp.png") will work and log a screenshot if you use Sikuli wrapper as it is described in this blogpost.

      Delete
    5. Yesterday I had time to understand your code. All work fine now, but I've made several changes. I'll list my comments here to help the others.
      1. click(img) would work work only if Region defined. Because wrapper exists only for Region.click. Normally I define region, but in that simple test I didn't.
      2. I've added wrapper for Region.find()
      3. I've changed def exists(self, target, timeout=None) to def exists(self, target, timeout=1)
      4. path to images was hardcoded in wrapper:
      ----------------------------------------------
      except FindFailed, e:
      self.log.html_img("Find Failed", "images/" + getFilename(target))
      ----------------------------------------------
      I've changed it to :
      ----------------------------------------------
      except FindFailed, e:
      self.log.html_img("Find Failed", common.cfgImageLibrary + '/' + getFilename(target))
      -----------------------------------------------
      so the only place where u need to specify image path is common.py
      5. And don't forget to add
      addImagePath(common.cfgImageLibrary)
      to your sikuli library file

      Delete
    6. Thank you for adding the comment. I would ask you to mention version of OS, Sikuli and RobotFramework you used in your setup so other will have a clear picture such as versions mentioned in the blogpost are slightly outdated right now.
      I have completed this example and blogpost more than 2 years ago, and since that time I have never worked with Sikuli any more. A half a year ago I switched to another company and stopped using RobotFramework.
      So mainly thankfully to comments like yours this blogpost is still live.

      Thank you again!

      Delete
  80. Azharuddin KunotjiOctober 8, 2013 at 4:12 PM

    Hi Mykhailo,

    I have similar problem as mentioned above by Tobokeru. I have tried all the things that she told to do.
    I am still not getting failure image on FIND failure. my def click class is as shown

    def click(self, target, modifiers=0):
    setLogEntry("CLICK: " + str(getFilename(target)))
    try:
    if isinstance(target, str) or target.__class__.__name__=="Pattern" or isinstance(target, basestring):
    self.log.html_img("Clicking...", common.cfgImageLibrary + '/' + getFilename(target))
    else:
    if target != None:
    self.log.screenshot(msg="Click Region...", region=(target.x-100, target.y-100, 200, 200))return SikuliRegion.click(self, target, modifiers)

    except FindFailed, e:
    if isinstance(target, str) or target.__class__.__name__=="Pattern" or isinstance(target, basestring):
    self.log.html_img("Find Failed", common.cfgImageLibrary + '/' + getFilename(target))
    else:
    if target != None:
    self.log.screenshot(msg="Find Region Failed", region=(target.getX()-100, target.getY()-100, 200, 200))
    self.log.screenshot(msg="Region", region=(self.getX(), self.getY(), self.getW(), self.getH()))
    #to write to a file on find failure
    fout = open('Output\\Result.doc', 'a')
    fout.write("\n")
    fout.write("Find Failed on Click operation : FAIL")

    raise e

    I am not getting failure image, but if I use the below code in other functions I am able to get the screenshot for all the functions..
    screen = Screen()
    file = screen.capture(screen.x, screen.y, screen.w, screen.h)
    print("Saved screen as "+file)
    name = self._get_unique_name(suffix=".png")
    shutil.copy(file, "results/screenshots/" + name)
    please help me out to get a screenshot on failure. I have written everything else similar to what u have mentioned. my logger file is the same and sikuli wrapper file is also same.

    thanking you in advance

    ReplyDelete
  81. Hi Mike,
    This is an excellent blog. This has changed my insight to automation. Thanks for it.
    I am trying this set up with Java (Java + Sikuli + RF). A simple google search one. Java, sikuli code runs fine. Even the RF, Java runs fine. But I am having issues when i club all 3 (Java,sikuli and RF). here is my java file. I have added the java code into robotframework jar file.
    No errors are shown.
    package rf.java;

    import org.sikuli.script.App;
    import org.sikuli.script.FindFailed;
    import org.sikuli.script.Screen;

    public class GoogleSearch {
    public static void openApp(){
    App.open("C:\\Program Files\\Internet Explorer\\iexplore.exe");
    }

    public static void openGoogle() throws InterruptedException, FindFailed{
    Screen s = new Screen();
    s.type("img/1378697905588.png", "www.google.com.au");
    s.type("\n");
    s.type("Key.ENTER");
    s.type("img/1381291211278.png", "sikuli java tutorial");
    s.type("\n");
    s.type("Key.ENTER");
    }
    }

    ReplyDelete
    Replies
    1. Well, what actually happens in your case, since no errors are shown? Does it fail the test? Does it not do what you want it to do (from visual monitoring/inspection), in which case, what do you see it doing instead?

      Delete
  82. hi Mykhailo,when I execute following command(same as yours example0 :
    java -jar "D:\Tech\sikuli-script.jar" calc.sikuli
    "[error] Did not find any valid option on command line!" was displayed

    but when I made a little change, execute following command:
    java -jar "D:\Tech\sikuli-script.jar" -r calc.sikuli
    the script works.
    Do you know why?

    ReplyDelete
  83. Hi,

    I am using the sikuli robot framework, for one of windows application,
    Having the method in logger.py, def passed and def screenshot, when the test case is passed, the screenshot is taken and put in folder where the jybottest.bat is running,
    where do we configure the path where screenshot, results%timestamp%.png to be copied.

    I have the requirement to zip these screenshots, and send across, so i need to modify the screenshots path, so that when i open the log file the screenshots are shown in the log file.

    when i try moving the screenshots to a diff folder, the images are not shown in log file.

    Please advise.

    the function in logger.py where the path is mentioned is as below:-




    Thanks,
    Vinod

    ReplyDelete
    Replies
    1. path of image as in def html_img in logger.py

      Delete
  84. Hi, I'm very grateful with your guide, but now i'm having a problem: i sucessfully follow this guide a month ago and now the script is not running, i got no errors and no messages from the command prompt, i just execute the command then it took like 5 seconds and continue to a new command prompt, do you have any tip or advice?

    thanks
    Raul

    ReplyDelete
  85. Not able to run the sikuli script from command line...can anyone help me !!! :-(

    ReplyDelete
    Replies
    1. Getting the following error
      Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
      at java.lang.String.substring(Unknown Source)
      at edu.mit.csail.uid.ScriptRunner.getPyFrom(ScriptRunner.java:87)
      at edu.mit.csail.uid.ScriptRunner.runPython(ScriptRunner.java:81)
      at edu.mit.csail.uid.SikuliScript.main(SikuliScript.java:76)

      Delete
  86. these pages helped me to run sikuli-x:
    http://www.sikulix.com/
    http://www.sikulix.com/quickstart.html

    ReplyDelete