Sikuli in Java - How do I capture the screenshots/Png?

automation, java, sikuli

Solution

public static void takePictureOfError(String Name) throws IOException,
        AWTException {
    new File("Errors").mkdir();
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    Dimension screenSize = toolkit.getScreenSize();
    Rectangle screenRect = new Rectangle(screenSize);
    Robot robot = new Robot();
    BufferedImage image = robot.createScreenCapture(screenRect);
    utilsLogger.info(ImageIO.write(image, "png", new File("//"
            + Name)));
}

I hope this methode helps, it has worked for me ;)

Problem

``` public class MyFirstSikuliTest { public static void main(String[] args) { App.open("C:\\Program Files\\Mozilla Firefox\\firefox.exe"); Screen s = new Screen(); try{ s.click("How do I take the screenshot and pass the path of the PNG here?", 0); s.wait("How do I take the screenshot and pass the path of the PNG here?"); s.type(null, "WEBSITE NAME", 0); } catch(FindFailed e){ e.printStackTrace(); } } } ``` How do I take the screenshot and pass the path of the PNG into click method and wait method?? kindly help. PS: I want to open firefox browser, click in the address bar, enter a website name and click enter. Thanks!

Original source