sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #24535
Re: [Question #244887]: Condition under if-elif is not working.
Question #244887 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/244887
Status: Open => Answered
RaiMan proposed the following answer:
supposing script1 at least contains:
from sikuli import *
# …
question2 = <some image or pattern>
# …
radioOption1 = <some image or pattern>
# same for the other radioOptionN
# …
def FeedbackQuestion(question):
find(question)
num = random.randint(1,5)
print(num)
if num==1:
click(radioOption1)
elif num==2:
click(radioOption2)
elif num==3:
click(radioOption3)
elif num==4:
click(radioOption4)
elif num==5:
click(radioOption5)
print("question and option selection was successful")
then in script2
import script1
script1.FeedbackQuestion(script1.question2)
should either click one of the five buttons or should throw a FindFailed
exception on question2 or the respective button image.
BTW: a shortcut:
def FeedbackQuestion(question):
find(question)
num = random.randint(1,5)
print "button to click:", num
eval("click(radioOption%d)" % num)
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.