How to select a particular image

Asked by Prateek Sahu

Is there a way to select a specific image when there are many similar images present on the screen???

Please help

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Steen (steenc) said :
#1

after you have made a Click("png")

if you click the picture!
and go to target offset!

the yellow crosshair sets the click.

Revision history for this message
RaiMan (raimund-hocke) said :
#2

You can use findAll() and loop through the matches, to find the right one.

for a first idea: see the docs

Revision history for this message
Prateek Sahu (prateek-sahu01apr) said :
#3

No RaiMan this is not the problem let me explain a little bit

I am using sikuli for a web application
When the web page is completely loaded it has a image lets say image.png

Now sikuli click on a link the application refreshes and a new element same as image.png appears at different location( it disappears from prvious location).

So what sikuli is doing it takes first image.png

and I have used image.png in wait(image.png,30)
So script does not wait for the second occurance of this image.png and proceed with the script...

Please help me....

Revision history for this message
RaiMan (raimund-hocke) said :
#4

ok, I understand.

maxWait = 30 # adjust to your needs
while maxWait > 0:
    if exists(image.png, 0): # check for image once
        reg = Region(getLastMatch())
        while reg.exists(image.png, 0): # check if image is still in same place
            wait(1) # time to be adjusted
        # loop again to check for image in another place
    else:
        wait(1)
        maxWait -= 1

I use exists(img.png, 0), because this only searches once, so you have a chance to influence general timing.

The workflow finds the image somewhere and waits for it to vanish in this place and then starts all over again finding the image now in another place.

Can you help with this problem?

Provide an answer of your own, or ask Prateek Sahu for more information if necessary.

To post a message you must log in.