sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #33803
Re: [Question #197294]: Can Sikuli Methods be Overridden?
Question #197294 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/197294
Ryan posted a new comment:
I too am hoping for something similar. In my project we are extending
the Region class extensively and sometimes need click to have a side
effect on the derived class.
For example:
class checkBox(parentClass): #parentClass is a hierarchy of super classes that implement different domain-specific actions
# Parent class eventually inherits from Region and initializes the actual region
def __init__(self, region, isSelected):
super(checkBox, self).__init__(region) # The super class passes the actual region bounds all of the way up to Region()
self.isSelected = isSelected
def click(self):
super(checkBox, self).click()
self.isSelected = not self.isSelected
This way I can always do the following:
component = checkBox(regionInfo)
component.click()
I like to keep my elements polymorphic to save lots of code across the
automation and references can be passed around based on what is actually
found on the screen. Without trying to override click() I am able to use
component.click() to click in the center of the component's region.
I get a recursion error when I use the code shown.
When I try to use parentClass.click() within the click() method I get:
TypeError: click(): expected 1-3 args; got 0
Based on this exception it sounds like I really just need to provide
some kind of region/instance so I tried to pass self in since it is a
region, and even strip the region from the class so that I'm just
passing a region: UIBaseClass.click(self)
Though this is a single argument I get: TypeError: click() takes exactly
1 argument (3 given)
Is there something that can be done to provide the correct argument?
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.