Automation Testing

SikuliX and Java Getting Started Video

By Test Guild
  • Share:
Join the Guild for FREE

I recently spoke with the main developer and maintainer of SikuliX, Raimund Hocke, on Episode 40 of my TestTalks podcast. What's cool about SikuliX is that it allows you to automate anything you see on your screen using image-based testing. After speaking with Raimund I thought it would also be helpful to create a quick video to show you just how easy it is to get started with SikuliX.

After you try this example, be sure to listen to Raimund Hocke: Getting Started with SikuliX Image-Based Testing on TestTalks for a deeper dive into SikuliX.

For this illustration, I'll be using Java and Maven.

Create a new Maven project then add the SikuliX repository information in your pom.xml file. Since SikuliX is still under development, you'll need to add the location to the snapshot stored on OSSRH:

    <repositories>

    <repository>

        <id>com.sikulix</id>

        <name>com.sikulix</name>

        <url>https://oss.sonatype.org/content/groups/public</url>

        <layout>default</layout>

        <snapshots>

        <enabled>true</enabled>

        <updatePolicy>always</updatePolicy>

        </snapshots>

        </repository>

    </repositories>

Next add the SikuliX and JUnit dependency information in your pom.xml file:

<dependency>
<groupId>com.sikulix</groupId>

    <artifactId>sikulixapi</artifactId>

     <version>1.1.0-SNAPSHOT</version>
</dependency>

<dependency>

     <groupId>junit</groupId>

     <artifactId>junit</artifactId>

     <version>4.11</version>

  </dependency>

Next create a new class named DemoTest


Create a new folder in your project named images


Open up the DemoTest class and add the following import statements:

import org.sikuli.script.*;

import static org.junit.Assert.*;

Right click on your project and Run as Maven Install

Create a Screen instance. The Screen allows you to click on regions within the screen:

    Screen s = new Screen();

Open up your Calculator and capture images for all the areas of the Calculator that you want to interact with. For this example I'm clicking on 8 * 3 = and verifying the total of 24. Save your images to the images directory we created earlier. (I'm using Snagit to get the images.)

Next let's add the actions we want to perform against the Calculator. Pretty much everything we are doing is a click, so add the following:

import org.sikuli.script.*;

import
static org.junit.Assert.*;

public
class DemoTest {

    public
static
void main(String[] args) {

        Screen s = new Screen();

     try {

            s.click(“images/8.png”);

            s.click(“images/multiply.png”);

            s.click(“images/3.png”);

            s.click(“images/equals.png”);

            assertNotNull(“Verify correct value”, s.exists(“images/result.png”));    

        } catch (FindFailed e) {    

            e.printStackTrace();

        }

    }

}

I also added an assertNotNull to verify the value that I expected to exist (24).

Right click on the DemoTest.java and run as a Java Application

If everything goes as planned you should have no errors in your console output!

I hope this helps and whets your appetite for learning more about image-based testing using SikuliX. (Note: An excellent resource for learning more is Raimund's SikuliX website.)

Optimized Bio with Podcast Longevityfor

Maximum Credibility & SEO

A bearded man with blue glasses and a black-and-white jacket smiles at a microphone in a studio setting.

About Joe Colantonio

Joe Colantonio is the founder of TestGuild, an industry-leading platform for automation testing and software testing tools. With over 25 years of hands-on experience, he has worked with top enterprise companies, helped develop early test automation tools and frameworks, and runs the largest online automation testing conference, Automation Guild.

Joe is also the author of Automation Awesomeness: 260 Actionable Affirmations To Improve Your QA & Automation Testing Skills and the host of the TestGuild podcast, which he has released weekly since 2014, making it the longest-running podcast dedicated to automation testing. Over the years, he has interviewed top thought leaders in DevOps, AI-driven test automation, and software quality, shaping the conversation in the industry.

With a reach of over 400,000 across his YouTube channel, LinkedIn, email list, and other social channels, Joe’s insights impact thousands of testers and engineers worldwide.

He has worked with some of the top companies in software testing and automation, including Tricentis, Keysight, Applitools, and BrowserStack, as sponsors and partners, helping them connect with the right audience in the automation testing space.

Follow him on LinkedIn or check out more at TestGuild.com.

  1. I got the error

    Exception in thread “main” java.lang.NoSuchMethodError: org.sikuli.basics.Debug.logx(ILjava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)V
    at org.sikuli.script.Screen.log(Screen.java:33)
    at org.sikuli.script.Screen.initScreens(Screen.java:95)
    at org.sikuli.script.Screen.(Screen.java:53)
    at com.mindtree.demo.SikuliDemo.main(SikuliDemo.java:8)

  2. Thanks for sharing this. In a windows based browse dialog window if we need to type in the path of a file, can we use sikulix

Comments are closed.

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Solving the Top 6 Mobile Automation Challenges Fast (DevAssure Guide)

Posted on 02/27/2025

Are you tired of struggling with the mobile test automation setups? Does managing ...

Top Software Testing Conferences (2025 Guide)

Posted on 01/19/2025

Why a list of top software testing conferences? Many testers ask me what ...

Top 8 Automation Testing Trends Shaping 2025

Posted on 01/11/2025

As we enter 2025, here are some automation testing trends I think will ...

AG '25 Online Event: Defeat Flaky Tests, Future-Proof Your Skills, & Grow Your Network in 2025 - Learn More >>

⭐⭐⭐⭐⭐ “A must-attend virtual event for all testing professionals.” — George Ukkuru (Head of Quality Eng.)