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:
- [Original] https://github.com/imikemo/Sikuli-and-Robot-Framework-Integration
- [Updated by Tset Noitamotua] https://github.com/Tset-Noitamotua/Sikuli-and-Robot-Framework-Integration/tree/Windows-8.1
- 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.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteHi,
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.
Hi,
ReplyDeleteI 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
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
Here is the 1st one (which I posted in the blog but got lost)
ReplyDelete***************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
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?' :)
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.
ReplyDeleteI 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.
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.
ReplyDeleteHi Mykhailo
ReplyDeleteGreat 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
==============================================================================
Hi Mykhailo.
ReplyDeleteCongratulations 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.
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?
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.
Hi am anji,,,
ReplyDeleteI 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,,,
I FINALLY got my x86 to work by adding the following to the jybottest.bat file:
ReplyDeleteset 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.
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
Hi Mykhailo!
ReplyDeleteI 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?
Hi, Mykhailo
ReplyDeleteI 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
Hi, Mykhailo
ReplyDeleteI 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
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.
This comment has been removed by a blog administrator.
ReplyDeleteHi Mykh,
ReplyDeleteI 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
Hi Mykhailo,
ReplyDeleteYour 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.
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!
Hi Mykhailo,
ReplyDeleteI 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
Hi Mike,
ReplyDeleteThis 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");
}
}
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?
Deletehi Mykhailo,when I execute following command(same as yours example0 :
ReplyDeletejava -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?
Hi,
ReplyDeleteI 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
path of image as in def html_img in logger.py
DeleteHi, 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?
ReplyDeletethanks
Raul
Not able to run the sikuli script from command line...can anyone help me !!! :-(
ReplyDeleteGetting the following error
DeleteException 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)
these pages helped me to run sikuli-x:
ReplyDeletehttp://www.sikulix.com/
http://www.sikulix.com/quickstart.html
Hello Mykhailo,
ReplyDeleteThanks for your blog very useful.
On windows7, 64 bits, I use SikuliX Setup Build: 1.0.1 12NOV2013120000 , with python 27 and java 7 and java version "1.7.0_17"
and I have an issue when I run runtest.bat command :
C:\work\calc_step1>runtest.bat
[error] Did not find any valid option on command line!
usage:
[-c] [-d ] [-f ] [-h] [-i <[runner
(jython)]>] [-l ] [-r ] [-t
] [-u ] [-x]
----- Running SikuliX-IDE or SikuliX-Script -------------
-c,--console print all output to commandline (IDE
message area)
-d,--debug positive integer (1)
-f,--logfile a valid filename
(WorkingDir/SikuliLog.txt)
-h,--help print this help message
-i,--interactive <[runner (jython)]> start interactive session and/or select
ScriptRunner
-l,--load preload scripts in IDE
-r,--run run script
-t,--test runs script as unittest
-u,--userlog a valid filename
(WorkingDir/UserLog.txt)
-x,--splash show a splash screen to enter options
-----
path relative to current working directory or absolute path
though deprecated: so called executables .skl can be used too
------
anything after --
or after something beginning with --
go to script as user parameters (respecting enclosing ")
------
-d use this option if you encounter any weird problems
DebugLevel=3 and all output goes to /SikuliLog.text
----------------------------------------------------------------
C:\work\calc_step1>
thanks for help
Greg
Hello,
ReplyDeleteI'm running robottest.bat as indicated in the blog but I get an error
C:\work\calc_step1>robottest.bat robot_suite\verify_operations.txt
[ ERROR ] Invalid syntax in file 'c:\work\calc_step1\robot_suite\verify_operatio
ns.txt' in table 'Settings': Importing test library 'calc' failed: TypeError: lo
g(): 1st arg can't be coerced to String
PYTHONPATH: [u'c:\\work\\calc_step1\\calc.sikuli', u'C:\\work\\calc_step1\\calc.
sikuli', 'C:\\work\\calc_step1\\robotframework-2.5.5.jar\\Lib\\robot\\libraries'
, 'C:\\work\\calc_step1\\robotframework-2.5.5.jar\\Lib', 'C:\\work\\calc_step1\\
sikuli-script.jar\\Lib', 'C:\\work\\calc_step1\\sikuli-script.jar\\org', 'C:\\wo
rk\\calc_step1\\Lib', 'C:\\work\\calc_step1\\robotframework-2.5.5.jar\\Lib', '__
classpath__', '__pyclasspath__/', '.']
CLASSPATH: robotframework-2.5.5.jar;C:\work\calc_step1\sikuli-script.jar
Traceback (most recent call last):
File "C:\work\calc_step1\robotframework-2.5.5.jar\Lib\robot\utils\importing$py
.class", line 88, in _import
File "C:\work\calc_step1\robotframework-2.5.5.jar\Lib\robot\utils\importing$py
.class", line 88, in _import
File "c:\work\calc_step1\calc.sikuli\calc.py", line 2, in
from sikuli.Sikuli import *
File "C:\work\calc_step1\sikuli-script.jar\Lib\sikuli\__init__.py", line 6, in
[ ERROR ] Invalid syntax in file 'c:\work\calc_step1\robot_suite\verify_operatio
ns.txt' in table 'Settings': Importing test library '../sikuli-script.jar' faile
d: ImportError: No module named
PYTHONPATH: [u'C:\\work\\calc_step1\\calc.sikuli', 'C:\\work\\calc_step1\\robotf
ramework-2.5.5.jar\\Lib\\robot\\libraries', 'C:\\work\\calc_step1\\robotframewor
k-2.5.5.jar\\Lib', 'C:\\work\\calc_step1\\sikuli-script.jar\\Lib', 'C:\\work\\ca
lc_step1\\sikuli-script.jar\\org', 'C:\\work\\calc_step1\\Lib', 'C:\\work\\calc_
step1\\robotframework-2.5.5.jar\\Lib', '__classpath__', '__pyclasspath__/', '.']
CLASSPATH: robotframework-2.5.5.jar;C:\work\calc_step1\sikuli-script.jar
Traceback (most recent call last):
File "C:\work\calc_step1\robotframework-2.5.5.jar\Lib\robot\utils\importing$py
.class", line 94, in _import
==============================================================================
Verify Operations
==============================================================================
Verify that 2 + 2 = 4 | FAIL |
No keyword with name 'Start App' found.
------------------------------------------------------------------------------
Verify that 2 + 2 = 5 | FAIL |
No keyword with name 'Start App' found.
------------------------------------------------------------------------------
Verify Operations | FAIL |
2 critical tests, 0 passed, 2 failed
2 tests total, 0 passed, 2 failed
==============================================================================
Output: c:\work\calc_step1\results\output.xml
Report: c:\work\calc_step1\results\report.html
Log: c:\work\calc_step1\results\log.html
Here is my structure :
c:\work
c:\work\calc_step1
c:\work\calc_step1\calc.sikuli
c:\work\calc_step1\Lib
c:\work\calc_step1\libs
c:\work\calc_step1\robot_suite
I 'm using robotframework-2.5.5.jar under c:\work\calc_step1
sikuli-script.jar under c:\work\calc_step1 --> SikuliX 1.0.1
Jython 2.5.3
Python 2.7
Thanks for help
Greg
Hi Mike,
Deletethis is RaiMan from SikuliX (ongoing Sikuli development http://sikulix.com)
I think I put Greg on the road now (RFW 2.8.5 and SikuliX 1.0.1).
There is still some problem left with the calc.py, but I guess I will find the solution.
So no need to deal with Greg's questions up to now.
Raimund aka RaiMan
This comment has been removed by the author.
ReplyDeletehi, i have some problems with it . Could you help me?
ReplyDeleteenvironment:
Robot Framework 2.8.5 (Jython 2.5.2 on java1.6.0_38-ea)
error info:
D:\>D:\work\test2\jybottest.bat robot_suite\verify_operations.txt
Traceback (most recent call last):
File "C:\Python27\Lib\site-packages\robot\run.py", line 381, in
from robot.conf import RobotSettings
File "C:\Python27\Lib\site-packages\robot\__init__.py", line 47, in
from robot.rebot import rebot, rebot_cli
File "C:\Python27\Lib\site-packages\robot\rebot.py", line 306, in
from robot.conf import RebotSettings
File "C:\Python27\Lib\site-packages\robot\conf\__init__.py", line 26, in
from .settings import RobotSettings, RebotSettings
File "C:\Python27\Lib\site-packages\robot\conf\settings.py", line 19, in
from robot import utils
File "C:\Python27\Lib\site-packages\robot\utils\__init__.py", line 47, in
from .importer import Importer
File "C:\Python27\Lib\site-packages\robot\utils\importer.py", line 26, in
from .robotpath import abspath, normpath
File "C:\Python27\Lib\site-packages\robot\utils\robotpath.py", line 17, in
import urllib
File "C:\sikuliX\sikuli-script.jar\Lib\urllib.py", line 26, in
File "C:\sikuliX\sikuli-script.jar\Lib\socket.py", line 311
'error', 'herror', 'gaierror', 'timeout', 'sslerror,
SyntaxError: mismatched character '\n' expecting '''
C:\work\calc_step1>robottest.bat robot_suite\verify_operations.txt
ReplyDelete[ ERROR ] Invalid syntax in file 'c:\work\calc_step1\robot_suite\verify_operatio
ns.txt' in table 'Settings': Importing test library 'calc' failed: TypeError: lo
g(): 1st arg can't be coerced to String
PYTHONPATH: [u'c:\\work\\calc_step1\\calc.sikuli', u'C:\\work\\calc_step1\\calc.
sikuli', 'C:\\work\\calc_step1\\robotframework-2.5.5.jar\\Lib\\robot\\libraries'
, 'C:\\work\\calc_step1\\robotframework-2.5.5.jar\\Lib', 'C:\\work\\calc_step1\\
sikuli-script.jar\\Lib', 'C:\\work\\calc_step1\\sikuli-script.jar\\org', 'C:\\wo
rk\\calc_step1\\Lib', 'C:\\work\\calc_step1\\robotframework-2.5.5.jar\\Lib', '__
classpath__', '__pyclasspath__/', '.']
CLASSPATH: robotframework-2.5.5.jar;C:\work\calc_step1\sikuli-script.jar
Traceback (most recent call last):
File "C:\work\calc_step1\robotframework-2.5.5.jar\Lib\robot\utils\importing$py
.class", line 88, in _import
File "C:\work\calc_step1\robotframework-2.5.5.jar\Lib\robot\utils\importing$py
.class", line 88, in _import
File "c:\work\calc_step1\calc.sikuli\calc.py", line 2, in
from sikuli.Sikuli import *
File "C:\work\calc_step1\sikuli-script.jar\Lib\sikuli\__init__.py", line 6, in
Hello Mike,
Is there a fix to this issue?
Help will be much appreciated
Sure.This is already been solved. Skim through previous comments - you will see.
DeleteHi Mykhailo, with which IDE did you code all that?
ReplyDeleteCheers
Tset Noitamotua
Hi Tset,
DeleteI really like vim. You can find plenty of plugins for vim that will enable syntax highlighting and code completion for both python and even Robot Framework test files ;)
Also I used :TOhtml command in vim to generate html code samples you can see in this blog.
I was struggling to set up PyCharm, IntelliJ IDEA and Netbeans to get syntax highlighting and code completion for Sikuli AND Python/Jython. Finally i made it with IntelliJ IDEA 14.0.2.
DeleteHave often heared about vim but i´m afraid that there is a big learning curve to get started with vim(?)
@ Mike and Raiman
DeleteI gave VIM a try and I´m beginning to realy like it. But I have one question - is it possible to get syntax highlighting and code completion for python/jython AND Sikulix in VIM?
It is definitely possible. Python should be supported by default.Just enable syntax highlighting by typing command :syntax on
DeleteEnhanced scripts for python support is available http://www.vim.org/scripts/script.php?script_id=790
Installation instructions are simple - just copy file to the ~/.vim/syntax/ folder.
You can google for jython support - some time ago I used vim to develop on java ;)
Hi Mykhailo,
ReplyDeleteI did a little update of the last part of your tutorial to make it run on Windows 8.1 with Sikuli 1.1.0 (beta). Have a look here: https://github.com/Tset-Noitamotua/Sikuli-and-Robot-Framework-Integration/tree/Windows-8.1 if you like.
Cheers
Tset Noitamotua
Thank you! Added link to your project into references.
DeleteUpdated part 1 of the tutorial and started to add documentation to the wiki of the github repo:
ReplyDeletehttps://github.com/Tset-Noitamotua/Sikuli-and-Robot-Framework-Integration/wiki
Plan to make an update of the hole blog post in the wiki.
Hope it is usefull for somebody ;-)
Cheers
Tset Noitamotua
It is definitely useful. This blogpost still has 400 views per week, even being outdated.
DeleteMy main message was the idea of integration, not a full featured library etc.
I would be happy to add your updates to this blogpost, you can fire a few pull requests with your changes - so I would be able to merge them into original github project.
I am fully support any kind of additions and updates since I do not have time to work on it myself.
--Mykhailo
I`ll do a pull request as soon as i have updated the second part of your tutorial as well.
DeleteCan't wait to see the updated info. I'm kind of lost figuring out how to import sikuli successfully in Jython for the latest Sikuli release, using cross-platform install (sikuli-java.jar, sikuli-ide.jar, runIDE.cmd, libs folder all in same location)
Delete@Tset
ReplyDeleteThis is Raiman from sikulix.com, current developer of SikuliX.
Thanks for your work and the contributions on GitHub.
Next year ;-) I will go through and maybe add some comments.
... and on my list for version 1.2 is to support running a RFW suite directly as a "SikuliX script"
Hi Raiman, thanx! Every comment is welcome as i am not a professional developer, i am doing my first steps on the field of test automation and just started to learn python, robot framework and sikulix. To reach a high quality of the documentation it will be good if experienced programmers like you, Mike and others review my updates and point me in the right direction there needed.
DeleteYour comments will be much appreciated Raiman. Looking forward to that.
DeleteMay I add this link here just to keep track on the discussion about Jython support in PyCharm:
ReplyDeletehttp://blog.jetbrains.com/pycharm/2012/01/the-story-behind-jython-support-in-pycharm/
?
Cheers
Tset
Sure!
DeleteIt´s allmost done and working with Windows 7 AND 8.1
ReplyDeletehttps://github.com/Tset-Noitamotua/Sikuli-and-Robot-Framework-Integration/tree/Windows-8.1
Check it out!
Documentation is comming soon.
Tset
this is RaiMan from SikuliX:
Delete-- 1. Congrats to your great work on GitHub
-- 2. You should switch on the issue section there, to help users, to ask questions or add comments (this is wha I am posting here ;-)
-- 3. You should change the title line saying "Full source files for my blogpost
http://blog.mykhailo.com/2 ..." since this is irritating (the concrete repo contains your derived work)
-- 4. I am currently very busy with the final of SikuliX 1.1.0, so I will not have a chance, to look deeper into your work, but I will definitely do it.
cheers RaiMan
Thanks, Raiman!!! and thanks for the hint. I allready wondered why others have that issues button in their repos and me not. Now I found it, too. Issues aktivated :) + title changed.
DeleteHi Tset,
DeleteThank you for your great work. I will review pull requests later today-tomorrow and then I guess I would need to update instructions in blogpost too.
Will keep you updated...
Great work!
Hi Mike,
DeleteI´m just trying to give something back for your great tutorial. So I have to thank you! :-)
@ Mike / @ Raiman
ReplyDeleteI would like you to check some things before I do a pull request. May be some fixes should be done before.
Some issues that encountered:
- NullPointerException when using addImagePath: https://raw.githubusercontent.com/Tset-Noitamotua/Sikuli-and-Robot-Framework-Integration/Windows-8.1/documentation/images/error_NullPointerException_addImagePath.png
- Invalid BundlePath [error]: https://raw.githubusercontent.com/Tset-Noitamotua/Sikuli-and-Robot-Framework-Integration/Windows-8.1/documentation/images/error_invalid_BundlePath.png
- Unresolved references in IntelliJ IDEA: https://raw.githubusercontent.com/Tset-Noitamotua/Sikuli-and-Robot-Framework-Integration/Windows-8.1/documentation/images/todo_unresolved_references.png
My project structure in IntelliJ IDEA 14.02 Community Edition:
- https://github.com/Tset-Noitamotua/Sikuli-and-Robot-Framework-Integration/blob/Windows-8.1/documentation/images/JI-14.02_CE-IDE_Project-Structure.png
- https://raw.githubusercontent.com/Tset-Noitamotua/Sikuli-and-Robot-Framework-Integration/Windows-8.1/documentation/images/JI-14.02_CE-IDE_Setup_Project-Structure_00_Global-SDKs.png
- https://raw.githubusercontent.com/Tset-Noitamotua/Sikuli-and-Robot-Framework-Integration/Windows-8.1/documentation/images/JI-14.02_CE-IDE_Setup_Project-Structure_01_Project-SDK.png
- https://raw.githubusercontent.com/Tset-Noitamotua/Sikuli-and-Robot-Framework-Integration/Windows-8.1/documentation/images/JI-14.02_CE-IDE_Setup_Project-Structure_02_Modules_Sources.png
- https://raw.githubusercontent.com/Tset-Noitamotua/Sikuli-and-Robot-Framework-Integration/Windows-8.1/documentation/images/JI-14.02_CE-IDE_Setup_Project-Structure_03_Modules_Paths.png
- https://raw.githubusercontent.com/Tset-Noitamotua/Sikuli-and-Robot-Framework-Integration/Windows-8.1/documentation/images/JI-14.02_CE-IDE_Setup_Project-Structure_04_Modules_Dependencies.png
- https://raw.githubusercontent.com/Tset-Noitamotua/Sikuli-and-Robot-Framework-Integration/Windows-8.1/documentation/images/JI-14.02_CE-IDE_Setup_Project-Structure_05_Libraries.png
- https://raw.githubusercontent.com/Tset-Noitamotua/Sikuli-and-Robot-Framework-Integration/Windows-8.1/documentation/images/JI-14.02_CE-IDE_Setup_Project-Structure_05_Libraries_2.png
Unresolved references problem solved thanks to Raiman´s answer on Sikuli launchpad: https://answers.launchpad.net/sikuli/+question/261129.
DeleteAs Raiman suggests I removed all java level imports and used s = Screen() at start of the scripts to avoid "undotted method calls" like wait(), click(), find(), exists() etc instead calls now look like s.wait(), s.find(), s.click() etc. Thus there is no mix of python and java level imports.
I moved everything from here to my github's repo issue section:
Deletehttps://github.com/Tset-Noitamotua/Sikuli-and-Robot-Framework-Integration/issues
I have a sikuli script for opening a firefox browser by doubleclick icon on my windows7 desktop and I am able to run this from command line. Its working as expected.
ReplyDeleteI want to run the same script from robot framework without using selenium library.
I have integrated both sikuli and RFW. But I am not getting the keywords part. What are the keywords we need to use so that both RFW and sikuli script will run simultaneously. Please help me on how to do this.
As this is no keyword library but an example of a general concept you will have to create your keywords yourself. This tutorial shows how to accomplish this.
DeleteIt´s faster to start an apllication from command line (cmd) than doppel clicking on the desktop. For example you could define a function like this:
def start_Firefox(self):
cmd = r'"C:/Program Files (x86)/Mozilla Firefox/firefox.exe"'
But if you still want to doppelclick then define a function like that:
def clickFirefoxIcon(self):
find("firefox_icon.png")
click("firefox_icon.png")
you will have to save a screenshot of your firefox desktop icon as firefox_icon.png in the images folder.
In your robot file (.txt or .robot) then you can call the keyword "Start Firefox" or "Click Firefox Icon" (wihtout the " ") in any test case. To quickly try this out take calc.py from step_3/calc.sikuli folder of my updated files: https://github.com/Tset-Noitamotua/Sikuli-and-Robot-Framework-Integration/blob/Windows-8.1/step_3/calc.sikuli/calc.py
Put the above mentioned function under class Calculator(BaseLogger) just like the other functions you see there - adjust the path to your firefox.exe of course. Then modify the file verify_operations.txt (https://github.com/Tset-Noitamotua/Sikuli-and-Robot-Framework-Integration/tree/Windows-8.1/step_3/robot_suite) from step_3/robot_suite folder like this:
Under ***Test Cases*** create a new test case (e.g. Launch Firefox) und put the keyword "Start Firefox" or "Click Firefox Icon" there. Save and run jybottest.bat or robottet.bat (depending on what you installed and configured correctly). Have fun!
Cheers
Tset
NOTE: the intendation here isn´t correctly. And by doppel clicking and doppelclick I mean a double click :)))) lol
DeleteHi Tset... Thanks for your comment. I have tried as per your comments. Still I am getting some errors as shown in my new comment. Can you please help me to fix this.
DeleteThanks in advance.
Hi Mykhailo, can u plz check this command line I´m doing:
ReplyDeletehttps://raw.githubusercontent.com/Tset-Noitamotua/Sikuli-and-Robot-Framework-Integration/Windows-8.1/documentation/images/jython%20-J-cp%20SyntaxError%20Non-ASCII%20character%20in%20sikulixapi.jar.png
Am I doing something wrong there or is it a bug in Jython?
@Tset Noitamotua... Thanks for your comment. When i run "calc.sikuli" I am getting following error:
ReplyDeleteC:\Users\test\Desktop\Projects\Sikuli Projects>java -jar "c:\robot\libs\sikuli
-script.jar" calc.sikuli
[info] Sikuli vision engine loaded.
[info] Windows utilities loaded.
[info] VDictProxy loaded.
[log] App.focus Calculator(0) #0
[error] CalcApp.png looks like a file, but can't be found on the disk. Assume it
's text.
[info] Text Recognizer inited.
[error] CalcApp.png looks like a file, but can't be found on the disk. Assume it
's text.
[error] CalcApp.png looks like a file, but can't be found on the disk. Assume it
's text.
[error] CalcApp.png looks like a file, but can't be found on the disk. Assume it
's text.
FAIL: No calculator window
[error] CalcApp.png looks like a file, but can't be found on the disk. Assume it
's text.
[error] CalcApp.png looks like a file, but can't be found on the disk. Assume it
's text.
[error] CalcApp.png looks like a file, but can't be found on the disk. Assume it
's text.
[error] CalcApp.png looks like a file, but can't be found on the disk. Assume it
's text.
[error] Can't run this Sikuli script: calc.sikuli
Traceback (most recent call last):
File "C:\Users\test\Desktop\Projects\Sikuli Projects\calc.sikuli\calc.py", l
ine 72, in
calc.runTest()
File "C:\Users\test\Desktop\Projects\Sikuli Projects\calc.sikuli\calc.py", l
ine 67, in runTest
self.performAction(*actions)
File "C:\Users\test\Desktop\Projects\Sikuli Projects\calc.sikuli\calc.py", l
ine 26, in performAction
find("CalcApp.png")
Line 46, in file C:\Users\test\Desktop\Projects\Sikuli Projects\calc.sikuli\
calc.py
at org.sikuli.script.Region.handleFindFailed(Region.java:421)
at org.sikuli.script.Region.wait(Region.java:512)
at org.python.proxies.sikuli.Region$Region$0.super__wait(Unknown Source)
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)
org.sikuli.script.FindFailed: FindFailed: can not find CalcApp.png on the screen
.
Line 46, in file C:\Users\test\Desktop\Projects\Sikuli Projects\calc.sikuli\
calc.py
C:\Users\test\Desktop\Projects\Sikuli Projects>
Then I tried to run py file itself. But still I am getting following error:
C:\Users\test\Desktop\Projects\Sikuli Projects\calc.sikuli>java -jar sikuli-sc
ript.jar calc.py
[info] Sikuli vision engine loaded.
[info] Windows utilities loaded.
[info] VDictProxy loaded.
[error] Can't run this Sikuli script: calc.py
IOError: [Errno 2] File not found - C:\Users\test\Desktop\Projects\Sikuli Proj
ects\calc.sikuli\calc.py\calc.py (The system cannot find the path specified)
C:\Users\test\Desktop\Projects\Sikuli Projects\calc.sikuli>
Please suggest me some ideas to fix this.
Thanks in advance.
Hi Naveen,
DeleteI think you are using an outdated sikuli version - sikuli-script.jar is a file from a old version. The new file is called sikulixapi.jar. I suggest you should instal SikuliX 1.1.0 and use this updated scripts: https://github.com/Tset-Noitamotua/Sikuli-and-Robot-Framework-Integration/tree/Windows-8.1 (NOTE: its not the master branch of this github repo, it´s branch Windows-8.1)
Follow this steps to install the latest Sikuli version 1.1.0:
1. download http://nightly.sikuli.de/sikulixsetup-1.1.0.jar
2. put it for example in C:\SikuliX_110
3. doubleclick it or in console cd into this folder (C:\SikuliX_110) and type java -jar sikulixsetup-1.1.0.jar and follow the installation instructions - I suggest to install all available options. After installation your Sikuli folder should look like this: https://github.com/Tset-Noitamotua/Sikuli-and-Robot-Framework-Integration/blob/Windows-8.1/documentation/images/SikuliX_Home.png
4. Create a system environment variable SIKULIX_HOME with the value C:\SikuliX_110\ (adjust to your Sikuli installation) and don´t forget the \ at the end. Then to your PATH variable ad this %SIKULIX_HOME%;%SIKULIX_HOME%libs
Now you should be able to run scrips with the runsikulix.cmd like this: cd into the folder which conains e.g. calc.sikuli folder and type runsikulix.cmd -r calc.sikuli
If you still run into errors check my readme file: https://github.com/Tset-Noitamotua/Sikuli-and-Robot-Framework-Integration/blob/Windows-8.1/README
Cheers
Tset
This comment has been removed by the author.
ReplyDeleteby executing the sikuli robot frame work i am getting below error:
ReplyDeletemain error is :[error] Phonebook-1.png looks like a file, but can't be found on the disk. Assume it's text
this is my log.html
TEST SUITE: Verify Operations1
Full Name:
Verify Operations1
Source:
C:\Users\maskp\Documents\Ddrive\SIKULI DOC\robot_suite\verify_operations1.txt
Start / End / Elapsed:
20150130 17:48:53.820 / 20150130 17:49:26.427 / 00:00:32.607
Status:
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
TEST CASE: Start App
Full Name:
Verify Operations1.Start App
Start / End / Elapsed:
20150130 17:48:56.373 / 20150130 17:49:26.412 / 00:00:30.039
Status:
FAIL (critical)
Message:
FindFailed: can not find maximise.png on the screen.
00:00:30.019 KEYWORD: MASkp.Calculator.Run Test
Start / End / Elapsed:
20150130 17:48:56.386 / 20150130 17:49:26.405 / 00:00:30.019
17:48:56.389 TRACE Arguments: [ ]
17:49:26.347 INFO FAIL: No VOT window
[log] App.open C:\Program Files (x86)\Vestas\VestasOnline Toolkit 4\Bootstrap.exe(11156)
[log] TYPE ""
[log] TYPE ""
[error] Phonebook-1.png looks like a file, but can't be found on the disk. Assume it's text.
[info] Text Recognizer inited.
[error] maximise.png looks like a file, but can't be found on the disk. Assume it's text.
17:49:26.369 FAIL FindFailed: can not find maximise.png on the screen.
17:49:26.374 DEBUG FindFailed:
Line ?, in File ?
at org.sikuli.script.Region.handleFindFailed(Region.java:421)
at org.sikuli.script.Region.wait(Region.java:512)
at sikuli.Region$py.wait$5(C:\Program Files (x86)\Sikuli X\sikuli-script.jar\Lib\sikuli\Region.py:102)
at sikuli.Region$py.call_function(C:\Program Files (x86)\Sikuli X\sikuli-script.jar\Lib\sikuli\Region.py)
at org.sikuli.script.Region.find(Region.java:382)
at org.sikuli.script.Region.getLocationFromPSRML(Region.java:1134)
at org.sikuli.script.Region.click(Region.java:607)
at org.sikuli.script.Region.click(Region.java:594)
at MASkp$py.VOTConnect$5(C:\Users\maskp\Documents\Ddrive\SIKULI DOC\MASkp.sikuli\MASkp.py:69)
at MASkp$py.call_function(C:\Users\maskp\Documents\Ddrive\SIKULI DOC\MASkp.sikuli\MASkp.py)
at MASkp$py.runTest$8(C:\Users\maskp\Documents\Ddrive\SIKULI DOC\MASkp.sikuli\MASkp.py:102)
at MASkp$py.call_function(C:\Users\maskp\Documents\Ddrive\SIKULI DOC\MASkp.sikuli\MASkp.py)
please help me on this, this is bit high priority in my project
DeleteHey,
DeleteIt can not find neither Phonebook-1.png nor maximise.png files on your disk.
Try to search for these files using file explorer, and then compare to the path you specified in sikuliwrapper.py:
https://github.com/imikemo/Sikuli-and-Robot-Framework-Integration/blob/master/calctest/CalcLib/sikuliwrapper.py
HI Myko,
ReplyDeletethanks for your suggestion and got solved that issue, but again i am facing new error.
please help me on below error(error is "FAIL IOError: [Errno 13] Permission denied: 'results/matches/2015-02-03_10-34-38.png' ")
TEST CASE: Start App
Full Name:
Verify Operations1.Start App
Start / End / Elapsed:
20150203 10:34:15.649 / 20150203 10:34:38.436 / 00:00:22.787
Status:
FAIL (critical)
Message:
IOError: [Errno 13] Permission denied: 'results/matches/2015-02-03_10-34-38.png'
00:00:22.779 KEYWORD: MASkp.Calculator.Run Test
Start / End / Elapsed:
20150203 10:34:15.654 / 20150203 10:34:38.433 / 00:00:22.779
10:34:15.655 TRACE Arguments: [ ]
10:34:38.422 INFO PASS: PASS: VOT window appeared
10:34:38.423 INFO Source Image
[log] App.open C:\Program Files (x86)\Vestas\VestasOnline Toolkit 4\Bootstrap.exe(5792)
[log] TYPE ""
[log] TYPE ""
10:34:38.429 FAIL IOError: [Errno 13] Permission denied: 'results/matches/2015-02-03_10-34-38.png'
10:34:38.430 DEBUG Traceback (most recent call last):
File "C:\Users\maskp\Documents\Ddrive\SIKULI DOC\MASkp.sikuli\MASkp.py", line 109, in runTest
self.verifyApp()
File "C:\Users\maskp\Documents\Ddrive\SIKULI DOC\MASkp.sikuli\MASkp.py", line 52, in verifyApp
self.log.passed("PASS: VOT window appeared")
File "C:\Users\maskp\Documents\Ddrive\SIKULI DOC\MASkp.sikuli\logger.py", line 52, in passed
self.screenshot(msg="Best Matches", folder='results/matches/', region=region)
File "C:\Users\maskp\Documents\Ddrive\SIKULI DOC\MASkp.sikuli\logger.py", line 40, in screenshot
shutil.copy(img_src, folder + name)
File "C:\Users\maskp\Documents\Ddrive\SIKULI DOC\robotframework-2.8.6.jar\Lib\shutil.py", line 85, in copy
copyfile(src, dst)
File "C:\Users\maskp\Documents\Ddrive\SIKULI DOC\robotframework-2.8.6.jar\Lib\shutil.py", line 52, in copyfile
fdst = open(dst, 'wb')
its working fine now.........!
DeleteHi, How did you sorted out this issue? Please share the details.
Deletehi Good Morning........!
ReplyDeletemy current script running through Sikuli IDE or tool but while executing with sukuli ride command"robottest.bat robot_suite\verify_operations1.txt" unable to execute the script:
here is my issue:-
My application has a menu item which is a sub-menu with 2 items and I cannot get Sikuli to select the second sub-item. I am using the following steps:
* click() on the main-menu
* click() on the sub-menu
* click() on the second item in the sub-menu
I have noticed that when the mouse moves from the sub-menu to the sub-menu item, it takes the shortest path which is a straight diagonal line. This path brushes the menu item that is just below the sub-menu and thus the sub-menu disappears, which makes my test fail. Is there a way to let Sikuli move the mouse first horizontally into the sub-menu and then vertically down to the item?
for that i have implemented below code to avoid disappear sub-menu:-
def clickOrtho(self, img):
start=Env.getMouseLocation()
end=find(img).getCenter()
mouseMove(Location(end.x, start.y))
mouseMove(Location(end.x, end.y))
click(end)
return end
def hoverOrhto(self, img):
start=Env.getMouseLocation()
end=find(img).getCenter()
mouseMove(Location(end.x, start.y))
mouseMove(Location(end.x, end.y))
hover(end)
return end
then also its not working. here problem is while mouse moving into sub-menu, before that sub-menu disappearing due to mouse move or time gap(i am not sure why and what).
so Could you please help me on this.
C:\Test>robottest.bat IE\tcase.txt
ReplyDeleteException in thread "main" Traceback (most recent call last):
File "", line 1, in
File "C:\Test\Lib\robot\__init__.py", line 16, in
File "C:\Test\sikuli-script.jar\Lib\os.py", line 118, in
ImportError: no os specific module found
I am getting this error when I am running the script via robotframework.jar
with jybot its running fine
I'm trying a simple little deviation but I cant get robot framework to work with sikuli.
ReplyDeleteI have a little example Library called ExampleLib.sikuli. Here are the contents of the ExampleLib.py:
from __future__ import with_statement
#from sikuliwrapper import *
#from sikuli.Sikuli import *
#addImagePath("ExampleLib.sikuli")
class ExampleLib:
def my_keyword(self):
"""does nothing"""
print("Yes mykeyword works for some reason")
pass
def your_keyword(self, arg):
"""Takes and Argument, does nothing"""
print("yourkeyword too... weird")
pass
def verifyApp(self):
if exists("1427206879174.png"):
print("yes!")
else:
print("no!")
pass
if __name__ == "__main__":
testInstance = ExampleLib()
testInstance.my_keyword()
testInstance.verifyApp()
So I should be able to work with my_keyword, your_keyword and verifyApp
In the Sikuli IDE it works.
I took your script, robottest.bat, and it goes like this:
set sikuli_jar=C:\SikuliX\sikuli-script.jar
java -cp "robotframework-2.8.7.jar;%sikuli_jar%" ^
-Dpython.path="%sikuli_jar%\Lib" ^
org.robotframework.RobotFramework ^
--pythonpath=ExampleLib.sikuli ^
--outputdir=results ^
--loglevel=TRACE ^
%*
Now, you see at the top of my ExampleLib.py that I commented out the imports.
When I run my robottest.bat with those lines commented out it gives me the expected:
NameError: global name 'exists' is not defined
When I uncomment any of the include lines the script runs.... and then just stops, gives no output and just punts me pack to the command line, without any error.
I don't know how to fix this. any clue what I could do?
Before anyone guesses: yes, the code was spaced correctly, the blogpost just smushed it all to the forefront ;)
DeleteNevermind. I updated to SikuliX 1.1.0 nightly and work with the sikulixapi.jar. That works :)
DeleteThanks for the great tutorial and on the offchance he reads this: Danke für das super tolle Projekt RaiMan :)
Hi, I'm making some research about what's the options available to with robot framework integrations and libraries to preform acceptance tests in mobile applications. And I came across this project.
ReplyDeleteIs Sikuli integration in robot framework a valuable option for mobile testing?
RaiMan from http://sikulix.com
DeleteSikuliX does not work on mobile devices and I doubt that RFW does (needs Python).
But you might run against the emulator on a desktop or use a VNC solution, to act on the device.
Hi mykhailo and raiman,
ReplyDeleteI've been tinkering with the example from this blog and the source code in github provided.
So far, I was able to integrate SikuliX 1.1.0 to RobotFramework and created custom keywords.
Still a bit rough, since I'm my knowledge in python is still limited. Anyway, I'm sharing this library to anyone interested. The installation instructions and how to run the demo test are in the following github link as well:
https://github.com/jaredfin/SikuliXRobotLibrary
Hi,
ReplyDeleteI'm trying to run Sikuli with robotframework from my eclipse on Mac machine...
I have jython & python interpreters configured on my eclipse and have the following run configuration that am truing to run:
"--output NONE --log NONE --report NONE --nostatusrc --loglevel TRACE /Users/MyUser/Documents/workspace/RobotFramework/Keywords/Sikuli.txt"
Inside Sikuli.txt I'm trying to use the capabilities of sikulilibrary, but its not working for me!
It's giving me all the time that it cant find the image!
I configured the image path and used it as follow:
***Settings***
Documentation Sikuli Library for Devices Testing
Test Setup Set Image Path
Test Teardown Stop Remote Server
Library SikuliLibrary
*** Variables ***
## Sikuli
${IMAGE_DIR} ${CURDIR}/img
*** Keywords ***
Set Image Path
Add Image Path ${IMAGE_DIR}
I had installed Sikuli IDE on my Mac as well, from IDE I manage to find images and run scripts...
How can I make it works from eclipse as well?
Regards.
Hi,
DeleteThanks for your comment.
Check if path to the images is correct, for example log ${IMAGE_DIR} variable from both IDEs. Also check this page http://doc.sikuli.org/faq/040-other-ide.html for information of how to setup Eclipse for Sikuli.
This is RaiMan from SikuliX (http://sikulix.com):
DeleteWith the latest version 1.1.1, it is possible to write and run RobotFramework scripts from SikuliX IDE or have an easy setup with SikuliX/RobotFramework in other IDE's like Eclipse/PyDev or PyCharm.
see: http://sikulix-2014.readthedocs.io/en/latest/scenarios.html#using-robotframework
This is RaiMan from SikuliX (http://sikulix.com):
ReplyDeleteWith the latest version 1.1.1, it is possible to write and run RobotFramework scripts from SikuliX IDE or have an easy setup with SikuliX/RobotFramework in other IDE's like Eclipse/PyDev or PyCharm.
see: http://sikulix-2014.readthedocs.io/en/latest/scenarios.html#using-robotframework
[sikuli] Stopped
ReplyDelete[sikuli] An error occurs at line 70
[sikuli] Error message:
Traceback (most recent call last):
File "C:\Users\ACER\AppData\Local\Temp\sikuli-tmp3070520366424854554.py", line 70, in
calc.runTest()
File "C:\Users\ACER\AppData\Local\Temp\sikuli-tmp3070520366424854554.py", line 61, in runTest
self.startApp()
File "C:\Users\ACER\AppData\Local\Temp\sikuli-tmp3070520366424854554.py", line 10, in startApp
calcApp = App("Calculator")
NameError: global name 'App' is not defined
Hello,
ReplyDeleteI am trying to run script from cmd. Followed your all instructions of section Step 1: Run Sikuli Script from command line. But showing error: java.lang.UnsatisfiedLinkError: VisionProxy.dll: Can't load IA 32-bit .dll on a AMD 64-bit
Hello Mykhailo,
DeleteI am using windows 7. I have also copied lib into following directory...
C:\Users\Local Settings\Temp\tempdir
But problem didn't solved.
Hello, here is solution for you: http://lmgtfy.com/?q=VisionProxy.dll
DeleteBtw, the same solution will work for other issues you might have :)
Hello,
ReplyDeleteI am having issue following this guide, since sikuli-script.jar no longer available in sikulixsetup-1.1.0. See Tset Noitamotua reply on January 24, 2015 at 5:14 PM
This guide is incomplete: https://github.com/Tset-Noitamotua/Sikuli-and-Robot-Framework-Integration
Content is not ready for this link https://github.com/Tset-Noitamotua/Sikuli-and-Robot-Framework-Integration/wiki/Step-1:-Run-Sikulix-Scripts-From-Command-Line
How to run sikuli script from command like and integrate with roobtframework using current sikulixsetup-1.1.0?
Please point me to a current working tutorial. Thanks!
One place to have a look (based on the great work of Mykhailo):
Deletehttps://github.com/Tset-Noitamotua/Sikuli-and-Robot-Framework-Integration
The current version of of SikuliX contains a convenience solution to start with RobotFramework integration:
http://sikulix-2014.readthedocs.io/en/latest/scenarios.html#using-robotframework
I am the current developer of SikuliX (RaiMan)