Search code examples
selenium-webdriverautomationsikuli

How to click on captured image using sikuli


enter image description hereI am new to Sikuli. I am Automating a web application that have option to upload a file. When I click on upload button it opens a popup window.In that window I have to select a file. How I can do it using sikuli. I am using linux operating system so I can't use AutoIT.

Below is my code which I am trying

 public static void imageClick()
     {
         Screen s= new Screen();
         try {

            s.capture();

            s.find("Desktop.png");
             s.click("Desktop.png",0);
             System.out.println("Desktop is selected");
        } catch (FindFailed e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

     }

Desktop.png is a image file which I kept in my project. first I am searching it then clicking on it.

Anyone can help me how I can achieve this. Any help will be highly appreciated.


Solution

  • Finally I done in in below way First import sikuli jar file to your project Capture the Image where you want to click and save it to some location for Ex. /home/dev/Desktop/abc.png

    Screen s = new Screen(); //Created the Object of screen class s.click("/home/dev/Desktop/abc.png");