sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #17243
[Question #225697]: Sikuli wrapper
New question #225697 on Sikuli:
https://answers.launchpad.net/sikuli/+question/225697
I have simple sikuli wrapper to log screenshots of patter in region to robot framework log. Originally copied by http://blog.mykhailo.com/2011/02/how-to-sikuli-and-robot-framework.html but slightly changed.
When I use region, which defined and saved in my regions.sikuli file, this wrapper works.
But if the region is created in code, like
region1.find(capture1).left().click(capture2)
it doesn't go through wrapper.
I've tried to save and print it:
r = region1.find(capture1).left()
print r
r.click(capture2)
print showed that r is a proper region (Region[0,270 254x43]@Screen(0)[0,0 1280x800] E:Y, T:3.0 E:Y, T:3.0), so r.click is a Region.click and it should go through wrapper.. but it didn't
Please help me make wrapper work with such cases as region1.find(capture1).left().click(capture2)
here is log from first case, when it goes through wrapper and I got screenshots, you an see sikuliwrapper is used:
FindFailed:
Line 370, in file C:\Python27\Lib\site-packages\robot\run.py
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\Sikuli X\sikuli-script.jar\Lib\sikuli\Region.py:102)
at sikuli.Region$py.call_function(C:\Program Files\Sikuli X\sikuli-script.jar\Lib\sikuli\Region.py)
at org.sikuli.script.Region.find(Region.java:382)
at sikuliwrapper$py.find$5(c:\robot\libs\sikuliwrapper.py:46)
at sikuliwrapper$py.call_function(c:\robot\libs\sikuliwrapper.py)
at org.sikuli.script.Region.getLocationFromPSRML(Region.java:1134)
at org.sikuli.script.Region.click(Region.java:607)
at sikuliwrapper$py.click$4(c:\robot\libs\sikuliwrapper.py:38)
at sikuliwrapper$py.call_function(c:\robot\libs\sikuliwrapper.py)
at pvalib$py.select_vt$15(c:\robot\libs\pvalib.sikuli\pvalib.py:136)
at pvalib$py.call_function(c:\robot\libs\pvalib.sikuli\pvalib.py)
at robot.utils.application$py._execute$10(C:\Python27\Lib\site-packages\robot\utils\application.py:88)
at robot.utils.application$py.call_function(C:\Python27\Lib\site-packages\robot\utils\application.py)
at robot.utils.application$py.execute_cli$5(C:\Python27\Lib\site-packages\robot\utils\application.py:45)
at robot.utils.application$py.call_function(C:\Python27\Lib\site-packages\robot\utils\application.py)
and here is log of the second case:
FindFailed:
Line 370, in file C:\Python27\Lib\site-packages\robot\run.py
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\Sikuli X\sikuli-script.jar\Lib\sikuli\Region.py:102)
at sikuli.Region$py.call_function(C:\Program Files\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 pvalib$py.select_vt$15(c:\robot\libs\pvalib.sikuli\pvalib.py:135)
at pvalib$py.call_function(c:\robot\libs\pvalib.sikuli\pvalib.py)
at robot.utils.application$py._execute$10(C:\Python27\Lib\site-packages\robot\utils\application.py:88)
at robot.utils.application$py.call_function(C:\Python27\Lib\site-packages\robot\utils\application.py)
at robot.utils.application$py.execute_cli$5(C:\Python27\Lib\site-packages\robot\utils\application.py:45)
at robot.utils.application$py.call_function(C:\Python27\Lib\site-packages\robot\utils\application.py)
and here is sikuliwrapper.py:
import common
from logger import *
from sikuli.Sikuli import Region as SikuliRegion
# enable slow motion if debug log level enabled
if common.cfgLoggingLevel.lower() == 'debug':
setShowActions(True)
# =============================================== #
# Overwritten sikuli methods #
# =============================================== #
# function for calling native sikuli methods
def sikuli_method(name, *args, **kwargs):
return sys.modules['sikuli.Sikuli'].__dict__[name](*args, **kwargs)
# overwritten Screen.exists method
def exists(target, timeout=1):
addFoundImage(getFilename(target))
BaseLogger.log.html(getFilename(target))
return sikuli_method('exists', target, timeout)
# =============================================== #
# Overwritten sikuli classes #
# =============================================== #
# overwriten Sikuli Region class
class Region(SikuliRegion, BaseLogger):
def click(self, target, modifiers=0):
try:
return SikuliRegion.click(self, target, modifiers)
except FindFailed, e:
self.log.html_img("Find Failed (click)", common.cfgImageLibrary + '/' + getFilename(target))
self.log.screenshot(msg="Region", region=(self.getX(), self.getY(), self.getW(), self.getH()))
raise e
def find(self, target):
try:
return SikuliRegion.find(self, target)
except FindFailed, e:
self.log.html_img("Find Failed", common.cfgImageLibrary + '/' + getFilename(target))
self.log.screenshot(msg="Region", region=(self.getX(), self.getY(), self.getW(), self.getH()))
raise e
def exists(self, target, timeout=1):
img = getFilename(target)
reg = (self.getX(), self.getY(), self.getW(), self.getH())
addFoundImage(img, reg)
return SikuliRegion.exists(self, target, timeout)
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.