Using Sikuli from Ruby - Codoid
Select Page
Codoid Blog

Using Sikuli from Ruby

Being a leading QA Company, we write blogs on all prominent software testing topics and tools using our real-world experience. So stay sharp by subscribing to our Newsletter.

Listen to this blog

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 SIKULIX_HOME environment variable and set the path of the Sikuli jar file

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")
  

Submit a Comment

Your email address will not be published.


Listen to this blog

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 SIKULIX_HOME environment variable and set the path of the Sikuli jar file

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")