click images in a loop (checkbox inside the image)

Asked by Samir

Hi,

In the following code asrS.png and asr34.png are unique small images, the images with checkbox in it.
How can I find a checkbox inside these images? Thanks for your help.

Following code does not work.

images = ("C:\polaris\asrS.png","C:\polaris\asr34.png")
for img in images:
    x = find(img) (it fails here)
    click(x.inside().find("1393256406284.png"))

In the above code, 1393256406284.png is a checkbox inside asrS.png and asr34.png images.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Samir
Solved:
Last query:
Last reply:
Revision history for this message
Eugene S (shragovich) said :
#1

Greetings,

I assume that the checkbox image is similar in both cases? If yes then you can do the following:

#Define a directory where your images are located:
bundlePath = "C:\polaris\"

#Run the command separately for each image:
find("asrS.png").find("1393256406284.png").click()
find("asr34.png").find("1393256406284.png").click()

Revision history for this message
Samir (samir198) said :
#2

Thanks Eugene.

It seems I might be doing something wrong but i tried exact same code given in the solution but it does not work for me.

Do you have any other suggestion?

The code does not recognize "bundlePath......" line and fails.

Revision history for this message
Eugene S (shragovich) said :
#3

Sorry, my mistake. Missed a line.

After you define your bundePath, you must apply it (set it) as follows:
setBundlePath(bundlePath)

or specifically in your case:
setBundlePath("C:\polaris\")

You can read more abot it here:
http://doc.sikuli.org/globals.html#setBundlePath

Cheers,
Eugene

Revision history for this message
Samir (samir198) said :
#4

Hi Eugene,

It looks like my IDE is incorrect?

Code I tried:
setBundlePath("C:\polaris")
find("asrS.png").find("1393256406284.png").click()
find("asr34.png").find("1393256406284.png").click()

Error:
find("asrS.png").find("1393256406284.png").click()
TypeError: click(): expected 1-2 args; got 0

Should I import any module for this.

Thanks.

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

click() is only available with version 1.0.1+ (which version are you using?)

BTW:
\ in strings must either be doubled or the string set as raw

setBundlePath("C:\\polaris") or
setBundlePath(r"C:\polaris")

Revision history for this message
Samir (samir198) said :
#6

Thanks RaiMan.

I do not have version 1.0.1.

For now, I will resolve the case as it seems 1.0.1 will help resolve my issue.

thanks to all for the help with the issue.