← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #244887]: Condition under if-elif is not working.

 

Question #244887 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/244887

    Status: Answered => Open

Atul Desai is still having a problem:
Hi RaiMan,
Thanks for your help the above code worked and is selecting the checkboxes randomly.
But now I am facing one more issue in we have optional field (a textarea) with each question and now my script is not able to distinguish between first question's textarea and second question's textarea, both have same title and size because of which the script is failing.
 
Example :
 
Q1 : Please rate
radioButton1 : Excellent
radioButton2 : Very Good
..
..
..
.. 
radioButtonn: poor
Comment (Textarea): ____________

Q2 : Please rate 2 
radioButton1 : Excellent
radioButton2 : Very Good
..
..
..
.. 
radioButtonn: poor
Comment (Textarea): ____________


I wrote below script but the code never enters if-elif condition block.

question1 = "1393923818615.png"
question2="1393843893700.png"
question3="1393843916859.png"
question4="1393843940775.png"
question5="1393843970900.png"
question6="1393843997667.png"

radioOption1 = "1393923605578.png"
radioOption2 = "1393923615559.png"
radioOption3 = "1393923628368.png"
radioOption4 = "1393923639294.png"
radioOption5 = "1393923648294.png"
radioOption6 = "1393936753939.png"
radioOption7 = "1393936763960.png"
radioOption8 = "1393936775294.png"
radioOption9 = "1393936785976.png"
radioOption10 = "1393936797938.png"

commentsField = "1393935801391.png"
commentFieldRegion1 = Region(235,220,970,314)

commentFieldRegion2 = Region(232,79,928,305)

options = {1 : radioOption1,
                2 : radioOption2,
                3 : radioOption3,
                4 : radioOption4,
                5 : radioOption5,
}
 
def FeedbackQuestion(ques, min, max):
    find(ques)
    num = random.randint(min,max)   
    print "button to click:", num
    eval("click(radioOption%d)" % num)
    test = ''.join(random.choice(string.ascii_lowercase) for x in range(4))
    if ques == question2:
        q = 1
        print "entered block2"
        type(Key.HOME)
        loc = SCREEN.getCenter()
        wheel(loc, WHEEL_DOWN, 6)
        eval("click(commentFieldRegion%d.find(commentsFields))" %q)
        type(commentsField,test)
    elif ques == question3:
        q = 2
        print "entered block2"
        type(Key.HOME)
        loc = SCREEN.getCenter()
        wheel(loc, WHEEL_DOWN, 6)
        eval("click(commentFieldRegion%d.find(commentsFields))" %q)
    type(commentsField,test)
    print "radiobutton selected"


Can you please help me to resolve this issue.

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.