0

I am just evaluating sikuli for one of our automation testing. I am trying to execute a script that can find the location of an image in a region.

This is the .sikuli script that I have written.

match = find("regionImage.png")  # The actual image here.
z = match.findAll("requiredImage.png")
for icon in z:
    print icon.getTarget()
    click(icon)
    time.sleep(3)

 #Output
 L(693,464)@S(0)[0,0 1920x1080]
 L(693,519)@S(0)[0,0 1920x1080]

The problem that I am having is getTarget gives the coordinates corresponding to the whole screen. What would be perfect is to get the location with respect to a set region. Is it possible? ( Ofcourse you can always subtract but just was wondering if there are any more good way )

user1429322
  • 1,266
  • 2
  • 24
  • 38

2 Answers2

1

the getTarget() method that you are using returns an object of class Location that in this case points to a center of current Match object. This match is not aware of the Region it was located in.

The only way to achieve your goal will be manual calculation. It should't be a complex task as Sikuli exposes a decent API in regards to patterns locations. Have a look at the documentation here to get some idea.

Eugene S
  • 6,709
  • 8
  • 57
  • 91
1

Maybe you are looking for .getX() and .getY().

Tenzin
  • 2,415
  • 2
  • 23
  • 36