This article is not related to Ruby-Cucumber. We are going to show you how to configure and code Sikuli in Ruby. Rukuli is the gem for Sikuli implementation in Ruby. Let’s jump into the snippets.
Requirements
SikuliX 1.0.1 (Install sikuli-java.jar (option 4) via sikuli-setup.jar)
JRuby is a high performance, stable, fully threaded Java implementation of the Ruby programming language.
Configure Sikuli Jar
Create
Install Rukuli Gem
gem install rukuli
Once the Gem installation and configurations are done, try the below snippets with expected images.
Wait for an image
require 'java' require 'rukuli' screen=Rukuli::Screen.new #Argument1: Image Path Argument2: Wait Time Argument3: similarity score region=screen.wait("C:image1.png", 10,0.7)
Click on image
require 'java' require 'rukuli' screen=Rukuli::Screen.new #Argument1: Image Path screen.click("C:image2.png")
Click on centre of an image
require 'java' require 'rukuli' screen=Rukuli::Screen.new region=screen.wait("C:image2.png", 10,0.7) screen.click(region.x+(region.width/2),region.y+(region.height/2))
Double click on centre of an image
require 'java' require 'rukuli' screen=Rukuli::Screen.new region=screen.wait("C:image3.png", 10,0.7) screen.double_click(region.x+(region.width/2),region.y+(region.height/2))
Type text on an image
require 'java' require 'rukuli' screen=Rukuli::Screen.new region=screen.wait("C:image4.png", 10,0.7) screen.click(region.x+(region.width/2),region.y+(region.height/2)) screen.type("Sample Text")
Comments(0)