Exploring the most useful tutorials for taking advantage of the Sikuli GUI automation testing device:
In the first segment of this “Sikuli tutorial series for beginners,” we went over Sikuli’s basic elements, its function, and how to put together a straightforward Sikuli task.
Recommended IPTV Service Providers
- IPTVGREAT – Rating 4.8/5 ( 600+ Reviews )
- IPTVRESALE – Rating 5/5 ( 200+ Reviews )
- IPTVGANG – Rating 4.7/5 ( 1200+ Reviews )
- IPTVUNLOCK – Rating 5/5 ( 65 Reviews )
- IPTVFOLLOW -Rating 5/5 ( 48 Reviews )
- IPTVTOPS – Rating 5/5 ( 43 Reviews )
This subsequent section delves into more complex notions, such as setting up a Sikuli Maven task and integrating Sikuli with Selenium WebDriver for webpage automation.
This aspect is integral due to the fact that Sikuli does not come with a built-in method for launching a website or web app. As a result, it’s essential to verify that the website is already loaded in a browser prior to running a Sikuli script, which could prove challenging.
This problem can be solved by coupling Sikuli with Selenium WebDriver. Selenium provides a means of launching a website within a browser, which facilitates the application of Sikuli scripts on such a website.
What You Will Learn:
Developing a Sikuli Maven Project
Eclipse Maven Plugin Installation
Step #1): Launch Eclipse, then head to Help -> Install New Software. Press the “Add” button and input the URL below.
Hit the “OK” button.
Step #2): Tick all listed checkboxes, hit “Next,” then install the Maven plugin.
Apache Maven Installation
Step #1): Download Maven’s latest version from this link.
Step #2): Decompress the downloaded zip file and save it in any place on your machine.
Duplicate Maven’s bin folder route and append it to the environment variable.
(JAVA_HOME variable in the environment variable is necessary for this. Please ensure the JAVA_HOME variable is included in your environment.)
Step #3): To confirm Maven’s correct installation, launch Command Prompt and input “mvn -version”. You should see something similar to this:
This output signifies the successful installation of Maven on your machine.
Installation of the Sikuli Script Jar in the Maven Repository
As referred to in the first section, you should already have the sikuli-script.jar. The next step is to install it in the Maven repository using the command shown below:
Mvn install: install-file -Dfile=D:JarsSikuli-r930win32Sikuli-IDEsikuli-script.jar -DgroupId=com.test.sikuli -DartifactId=sikuli -Dversion-1.0.1 -Dpackaging=jar
Development of the Sikuli Maven Project
Step #1): Open Eclipse and initiate a new Maven Project.
Step #2): Add the dependencies below to your POM file.
<dependency> <groupId>com.test.sikuli</groupId> <artifactId>sikuli</artifactId> <version>1.0.1</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> </dependency>
Step #3): Develop a package within src/test/java and create a class in that package. From here, you can commence writing the Sikuli script inside the class.
Sikuli Demo Program: Launch a File in Windows Explorer
Step #1): Build a Sikuli Maven Project following the instructions provided above.
Step #2): Save screenshots of all necessary elements within the Maven project.
- file.png
Step #3): Create a class called “Test1” and copy the code below into the Sikuli class.
package com.test; import org.junit.Test; import org.sikuli.script.FindFailed; import org.sikuli.script.Screen; public class Test1 { @Test public void openFileTest() throws FindFailed, InterruptedException { // TODO Auto-generated method stub Screen s = new Screen(); s.find("file.png"); s.doubleClick("file.png"); System.out.println("File icon clicked"); } }
Running the Sikuli Maven Project from the Command Prompt
Step #1): Start the Command Prompt and navigate to the directory of the project.
Step #2): Run the project from the command prompt using the command below:
mvn clean test -Dtest=Test1
The Comparison: Selenium Versus Sikuli
Combining Sikuli With Selenium WebDriver
Step #1): In Eclipse, set up a new Java Project by clicking New -> Java project.
Step #2):
- Right-click the Project, then tap on Build Path -> Configure Build Path.
- Switch to the Libraries tab.
- Click “Add External Jars” and add Selenium library jars along with sikuli-script.jar
Step #3): Create a package in the src/ folder and put together a class within this package.
Step #4): Save screenshots of all necessary website elements within the project.
Step #5): Copy and paste the following code in the class.
package com.test; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.support.ui.WebDriverWait; import org.sikuli.script.FindFailed; import org.sikuli.script.Screen; public class OnlinePainting { public static void main(String[] args) throws FindFailed { // TODO Auto-generated method stub WebDriver driver = new FirefoxDriver(); WebDriverWait wait = new WebDriverWait(driver, 20); driver.manage().window().maximize(); driver.get("http://www.thecolor.com/Coloring/a-puppy-with-a-kitten.aspx"); Screen screen = new Screen(); screen.wait("1398665726055.png", 20); screen.click("1398666382715.png"); screen.click("1398666248846.png"); screen.click("1398666729252.png"); screen.click("1398666188894.png"); screen.click("1398665763634.png"); screen.click("1398666592027.png"); screen.click("1398666610951.png"); screen.click("1398666308624.png"); screen.click("1398666326406.png"); screen.click("1398666570749.png"); screen.click("1398666703708.png"); screen.click("1398666382715.png"); screen.click("1398666857321.png"); screen.waitVanish("1398665763634.png"); } }
Final Thoughts
- Sikuli scripts can be smoothly incorporated with Selenium WebDriver for automating flash websites.
- Sikuli is capable of automating windows and other applications.
- Using visual matching, Sikuli can automate almost anything that is visible on the screen.
- It provides strong support for Flash objects, allowing for the automation of Adobe Flash Player components such as audio and video players.
- Sikuli scripts can be crafted as Maven projects and run from the command prompt.
- Overall, Sikuli is an accessible automation tool for automating demanding flash and windows applications.
Feel free to address any questions in the comments section below.