sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #28885
Re: [Question #255999]: Hi All, Please help me in solving this.
Question #255999 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/255999
Status: Open => Answered
RaiMan proposed the following answer:
this is a possible solution:
- packed your handling of one case into a function
- the function gets the variable terms as parameters
- returns False if not working
def checkSelected(p0, p1, p2, p3, txt)
click(Pattern(p0).targetOffset(68,4))
sleep(4)
type(txt)
sleep(2)
type(Key.ENTER)
sleep(4)
click(Pattern(p1).targetOffset(-45,16))
sleep(2)
click(Pattern(p2).targetOffset(-55,15))
mouseDown(Button.LEFT)
hover(Pattern(p3).targetOffset(50,15))
sleep(2)
mouseUp()
sleep(2)
type('c',Key.CTRL)
sleep(2)
z = Env.getClipboard().strip()
sleep(2)
if (z==y):
print txt, " - working fine"
return True
else:
print y, " - did not work"
return False
# the different cases are represented by a set of values for the parameters of the function
cases = (
("1413891453.png", "141388723.png", "14131.png", "141774.png", "Cancelled"),
("00.png", "01.png", "02.png", "03.png", "someOtherText")
)
for case in cases: # loop through teh given cases
if not checkSelected(case[0], case[1], case[2]. case[3], case[4]):
break # end loop since we have a problem
Since I do not know your exact setup: parameters that are fix for all
cases, can be taken from the list and the cases store and implemented as
global variables.
example if p0 is fix::
def checkSelected(p1, p2, p3, txt)
click(Pattern(p0).targetOffset(68,4))
sleep(4)
type(txt)
sleep(2)
type(Key.ENTER)
sleep(4)
click(Pattern(p1).targetOffset(-45,16))
sleep(2)
click(Pattern(p2).targetOffset(-55,15))
mouseDown(Button.LEFT)
hover(Pattern(p3).targetOffset(50,15))
sleep(2)
mouseUp()
sleep(2)
type('c',Key.CTRL)
sleep(2)
z = Env.getClipboard().strip()
sleep(2)
if (z==y):
print txt, " - working fine"
return True
else:
print y, " - did not work"
return False
cases = (
("141388723.png", "14131.png", "141774.png", "Cancelled"),
("01.png", "02.png", "03.png", "someOtherText")
)
p0 = "1413891453.png"
for case in cases: # loop through teh given cases
if not checkSelected(case[0], case[1], case[2]. case[3]):
break # end loop since we have a problem
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.