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:
- RIDE (Robot Integrated Development Environment)
easy-to-use editor for creating and maintaining test data.
- Provides easy-to-read reports and logs in HTML format.
- Provides a simple library API for creating customized test libraries.
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:
- Installation
- Run Sikuli Scripts using command line
- Upgrade Sikuli Scripts to Test Libraries
- Tips and tricks
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:
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:
- Copy sikuli-script.jar from Sikuli installation directory (by default "C:\Program Files\Sikuli") to the directory of your Sikuli project.
- Extract "Lib" directory from sikuli-script.jar to the directory of your Sikuli project.
- Add the following statement to the beginning of your Sikuli script:
1 from sikuli.Sikuli import * 2
Pic. 2 - Sikuli project layout
runtest.bat file is a batch file for running your Sikuli script:
Sikuli X
- 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\).
- 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.
- Download robotframework-2.5.5.jar file and place it to your Sikuli project directory.
- Run test cases using robottest.bat file, that is shown below, using command:
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.
- Install Python, Jython and Robot Framework
- 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")
- Run test cases using jybottest.bat file, that is shown below, using command:
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.
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.
- Sikuli and Robot Framework Integration Project on GitHub: https://github.com/imikemo/Sikuli-and-Robot-Framework-Integration
- Sikuli Project: http://sikuli.org/
- Robot Framework Project: http://code.google.com/p/robotframework/



Thank you, Andriy Kolodiy for review of this blog post. I owe you beer!
ReplyDeleteMad props Mike, this is testing goodness!
ReplyDeletegetting following error :
ReplyDeleteKEYWORD: 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')
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.
ReplyDeleteI 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.
ReplyDeletehttp://blog.labix.org/2010/05/18/xpresser-python-library-for-gui-automation-with-image-matching
Is there MAC version?
ReplyDeleteNo, there is no MAC version yet. I'll add it soon if needed.
ReplyDeleteHi. Greetings. This post is really good and blog is really interesting. It gives good details.
ReplyDeleteSoftware Testing Tutorial
Hi,
ReplyDeleteI am getting the following error:
No keyword with name 'click' found.
Subha
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.
ReplyDeleteAs 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.
Here is the 2nd one about which I told u:
ReplyDelete******************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
Hi Mykhailo Moroz,
ReplyDeleteI was able to solve the problem where it is taking the screen shot but not attaching it to the log file.
Regards
Subh
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.
ReplyDeleteHow to use Sikuli Script in your JAVA programs
http://sikuli.org/docx/faq/030-java-dev.html
Definitely good point. Remote library API is another strong side of Robot Framework :)
ReplyDeleteHi 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:
ReplyDelete"[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
Hi Thiago,
ReplyDeleteThe 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 ^
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.
ReplyDeleteOtherwise, 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.
Hello,
ReplyDeleteThis 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?
I should mention that I'm getting this error when running the cmd
ReplyDeleterobottest.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'.
Hi,
ReplyDeleteIt 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.
Thanks for the response. I still cannot get it to work.
ReplyDeletefrom 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?
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!
ReplyDeleteHi 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.
ReplyDeleteJust to let you know I ran it on:
Robot_2.5.7
Thanks a lot.
Hi everyone,
ReplyDeletehas 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!
Any idea how to get this to work with the just released RC3?
ReplyDeleteHere'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.
@nomdeplume i did the next to robottest.bat:
ReplyDelete-Dpython.path=..\robotframework-2.6.0.jar\Lib;"%sikuli_jar%/Lib" ^
And now the sikuli RC3 is working with RF.
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...
ReplyDeletehttp://code.google.com/p/simplesikuli/
Anybody over here get it running over RIDE ? If so, what you did to get it running without errors ?
ReplyDeleteAny help from the mates, please ?
Regards,
Thiago Felipe Peçanha
@man9ar00 I'll check the library when I get a chance.
ReplyDeleteThiago,
ReplyDeleteYou 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.
Hi, Congrats for the great job done here.
ReplyDeleteI'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
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.
ReplyDeleteI 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
Radu,
ReplyDeleteThis 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
Thanks a lot for the info.
ReplyDelete[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
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
ReplyDeletehttp://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?' :)
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:
ReplyDeletedef 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 ^
%*
I think you should set like that
Delete-Dpython.path="robotframework-2.5.5.jar\Lib;%sikuli_jar%\Lib" ^
Hi.mykhailo
ReplyDeletenice 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
Hi jayanti and mykhalio,
Deletedid 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.
This is the exact message:
DeleteC:\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
Hi Jayanti,
ReplyDeleteI 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.
Hi Jayanti and Mykhailo,
DeleteI 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
Hi Jiaqiang,
DeleteThank 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
Hi, Mykhailo,
ReplyDeletewhile 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
Hi Pol,
ReplyDeleteActually 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],) )"?
"...What do you expect to do with this line "click(Pattern("2.png").similar(0.80)%(args[0],) )"? ..."
ReplyDelete- 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
Pol,
ReplyDeleteIn 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"
Oh, thank you!
ReplyDeleteThat was confusing me.
Sorry for such stupid mistake, I should really read more manuals!
Pol
Ended up tweaking the batch file to this :
ReplyDelete@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.
Thanks, it run OK.
DeleteAwesome! Thank you very much for posting this.
ReplyDeleteI 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?
ReplyDeleteJava 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: '
Hi Greg,
DeleteIt 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
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.
Delete==============================================================================
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:\>
It seems your previous issue disappeared with Jython 2.5.1 installed and now you are moved further to ImportError.
DeleteFrom the error message it can be seen that Robot could not find SikuliLibrary. Make sure that path to its installation is present PYTHONPATH.
Adding the following did the trick.
ReplyDeleteset python=E:\Workspace\Trunk\python
set PYTHONPATH=%python%
I guess Jython 2.5.2 was the issue. Thanks for the help.
Well now it runs using Jython but I have another set of issues.
ReplyDeleteI 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?
I figured this out and here is the solution.
ReplyDeleteJava - 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.
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.
ReplyDeletethanks!
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.
Deletehttp://groups.google.com/group/robotframework-users
BTW, I monitor robotframework-users group and try to answer all the discussions where this blog post is mentioned.
DeleteI just tried on my Windows 7 and it works.
ReplyDeleteThanks for the great example.
I'd like to try on an Android device. Can you give an example.
Thank you much!
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.
DeleteNote 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.
hello,
ReplyDeleteUsing 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
it seems you have some issues with Sikuli IDE installation. Please make sure you followed all the installation steps from the official website.
DeleteGetting following error:
ReplyDeleteD:\>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
I'm getting the "TypeError: exists(): 2nd arg can't be coerced to double" error when running my script.
ReplyDeleteAnyone solve this problem yet?
I'm on Win7 32 bit, using Robot Framework 2.7.1, and Sikuli RC3
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?
ReplyDeleteLook into changes in a pull request to the github project:
Deletehttps://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.
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.
DeleteI'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!
Hi Mykhailo,
ReplyDeleteThanks 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
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\
DeleteHi there,
ReplyDeleteCould 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
Hi,
ReplyDeleteI 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.
Install 32bit Java JRE.
DeleteHi I run in WIN7 32bit.
ReplyDeletefrom sikuli.Sikuli import * <= ImportError
why??
Could you post the traceback here? It is hard to say what the exact reason on you case.
DeleteImportError means that sikuli module could not beed found and therefore imported.
main.py
ReplyDeleteimport 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
I try from command line.set classpath=C:\sikuli-script.jar
Deletethe issues still there.
CLASSPATH doesn't display from RIDE, but commandline has.
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.
DeleteThanks~you are right! I use .bat from command to running, now it is work fine.
DeleteBut 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
Hi @藍成浩,
DeleteCould 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
It seems that RIDE experiences issues when trying to load your library. You can look inside RIDE log for more details.
DeleteAccording 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!
Hi Mykhailo Moroz,
DeleteDo you run Calculator.py on Robot Framework RIDE? Could you give me more detail to run on RIDE?
Thanks,
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.
DeleteAdditionally 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.
Hi Mykhailo Moroz,
DeleteOk, It's working. Thank you so much.
Best regards,
Thankyou so much!!
ReplyDeleteThis is a great tutorial.. Thank you very much.
ReplyDeleteI 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:
Hi Durairaj,
DeleteI 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
Hi Mykhailo,
ReplyDeleteThank you. After posting, I found out the issue. Thank you very much.
Hi Mykhailo,
ReplyDeleteThanks 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
Hi Mykhailo,
ReplyDeleteWant 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
There is a problem on Robot Framework working with the Sikuli Tools (Jython/python).
ReplyDeleteIf 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
Hi, and thank you very much for the manual.
ReplyDeleteI 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 ^
%*
-----------------------------------------------------------
Hello,
DeleteI 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.
With your files I have an error in sikuliwrapper, but I can't figure out what's wrong:
Delete21: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)
I've fixed this error changing
Delete# 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")
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.
DeleteIn your example click("CalcApp.png") will work and log a screenshot if you use Sikuli wrapper as it is described in this blogpost.
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.
Delete1. 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
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.
DeleteI 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!