anuvrat singh
anuvrat singh

Reputation: 421

Sikuli: I am not able to click on an Element present in a PopUp window

I am new to the Sikuli API and I am using the Sikuli-java-jar file. I want to successfully click on a desktop element using the screen and pattern classes.

So I was trying to create an automation script to install software. I am able to successfully launch the installer but not able to click on the Next Button present in the pop-up window.

I am not getting any error, it is just that clicking on the image fails.

enter image description here enter image description here

appInstaller("E:\\Sikulimages\\tc.png");
        appInstallers("E:\\Sikulimages\\next.png");


public static void appInstaller(String path) throws FindFailed{
        s=new Screen();
        img=new Pattern(path);      
        s.exists(path);
        s.wait(img,2000);
        s.doubleClick(img);
    }

    public static void appInstallers(String path) throws FindFailed, InterruptedException{

        s=new Screen();
        img=new Pattern(path);      
        s.click(img);               
    }

Upvotes: 1

Views: 2583

Answers (3)

Umesh
Umesh

Reputation: 121

For installing application you need admin rights. So For running any task that require admin rights you need to run sikuli in admin mode. So right click on runSikulixcmd.bat and select Run as administrator for launching the Sikuli and then run the test.

If you are running the test from command prompt run it in admin command prompt.

Upvotes: 1

autoKarma
autoKarma

Reputation: 839

In addition to RPWheeler's answer, if there is something right next to your target image that will appear the same way every time, you can also take a bigger screen clip and then tell Sikuli which part of that bigger image to click on.

For example: if your "Next" button is part of a row of buttons, take the screen clip to include the whole row. Then, in the IDE, double click on the image, and go to the "Target Offset" tab. Here, you'll see an example of your image, and and you click on the part of the image you want Sikuli to click on. -- the default is always the center of the rectangle, but you can change it with the target offset.

You can accomplish the same thing in code like this

t = find(yourImage).targetOffset(dx,dy)
click(t)

where dx and dy are a positive or negative number of pixels away from the center point of the rectangle.

Upvotes: 1

RPWheeler
RPWheeler

Reputation: 36

I think that the reason is that default Similarity (0.7) is insufficient for small buttons and text.

Sikuli has public class Settings , which hosts public static double MinSimilarity = 0.7;

That value is good enough for most image recognition, but it fails for small texts. To get small text clicked, you need to raise similarity for particular pattern, or, like I do, make Settings.MinSimilarity = 0.9;

Sometimes even 0.9 is not enough to recognize small text, well, then try 0.95 , it is usually what helps to pinpoint even smallest texts.

Upvotes: 1

Related Questions