Madhu
Madhu

Reputation: 11

How to click on a particular Checkbox using sikuli

I'm very new to Sikuli.I was trying to automate a desktop application using Sikuli and Java,but i'm stuck with an issue .I'm unable to check the checkbox. The code that i have used is given below and it does not work

Pattern firstCheckBox = new Pattern("images/FeedsList/abc.PNG");
Pattern checkBox = new Pattern("images/FeedList/checkbox.PNG");
            Region r = feedSelectionScreen.find(firstCheckBox);
            r.hover();
            Region leftRegion = r.left();
            if(leftRegion.exists(checkBox)!=null){
                System.out.println("Hippee found check box oon left region");
                leftRegion.click(checkBox);
            }

Here firstcheckbox pattern is referring to the word image after the checkbox and checkbox is referring to the checkbox image. If anyone could help me on this,it is of great help to me. Thanks in advance.

Upvotes: 1

Views: 1562

Answers (1)

Tenzin
Tenzin

Reputation: 2505

I am not a star at programming in Java, becasue I don't do that language very often. But I think you have 2 options.

The first one (and the one I like the most) is to work with regions. With Sikuli you can define a region to work with. Within a reagion you can also look for certain images. Or in case of a checkbox, you can find the text that belongs with it and use a region to specify where the checkbox should be located.

Here is a link about regions in Sikuli: Link

Also you can use "Settings.OcrTextSearch = true" to have Sikuli search for text. (If you put that one on you have to delete the "libs" directory in your Sikuli installation folder. Else it won't update (=bug). If the filder "tessdate" is in "libs" it is fine.)

The other thing you can do is Sikuli to find all checkboxes on the screen. For example from Top-Left to Below-Right. Then it wil search the screen in that order. If the checkbox is the second one you need. Then you let it do something at the second find.

Upvotes: 1

Related Questions