← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #225941]: How to click on a text with same description

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
Nevertheless you can use findAll() and it helps you better to decide
which one to click:

matches = list(findAll(Pattern(img).similar(0.95))) # similarity as high as possible to avoid false positives
matches.sort(lambda m1, m2: m1.y > m2.y)

now matches contains the found matches in top down order, supposing the
targets are below each other.

Since you know the number of needed matches, you should check:
if len(matches) != 2: 
    print "findAll() did not work as expected"
    exit()

now you know:
matches[0] # is the upper one
matches[1] # is the lower one

and you can do with either one what you want, e.g.
click(matches[0]) # click the upper one

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