I’ve been impressed with the Sikuli (now SikuliX) project for a few years yet.
It has a few warts, but I like the concept of interacting with a GUI just like a user, using visual inspection. If an UI aspect of your software can’t be properly identified visually, it can’t be used in SikuliX – and in reality, neither can it be used by a human.
I’m also a fan of BDD-Style specifications – even more so if they can be made executable, e.g. through cucumber.
Recently I had to integrate SikuliX with Cucumber for a customer, and since it was a bit fiddly, I decided I was going to describe it here.
This description is for Ubuntu 15.10 “Wily”, but it’s also applicable for Debian 8 (perhaps with slight adaptations).
Installing SikuliX
We aren’t going to use the Sikuli packages provided by Canonical, since they are about two years old. However, we will install a bunch of required packages.
$ sudo apt-get install default-jre junit libcommons-cli-java libjxgrabkey-java libmac-widgets-java libswing-layout-java libswingx-java
$ sudo apt-get install libjnr-constants-java tesseract-ocr-eng wmctrl xdotool
$ sudo apt-get install libgcc1 libopencv-core2.4v5 libopencv-highgui2.4v5 libopencv-imgproc2.4v5 libopencv-objdetect2.4v5 libtesseract3v5
Next, create a directory that SikuliX will reside in, e.g.
$ mkdir ~/sikuli && cd ~/sikuli
Then, download the sikuli installer jar from http://www.sikulix.com/
$ wget https://launchpad.net/sikuli/sikulix/1.1.0/+download/sikulixsetup-1.1.0.jar
Run the installer:
$ java -jar sikulixsetup-1.1.0.jar
In its installation dialog, make sure you check the JRuby checkbox
After you’ve completed the installation, make sure it works by starting the default GUI (which we won’t be using for cucumber though).
./runsikulix
Installing JRuby and Cucumber
Now that SikuliX is installed and working, we need the plumbing to get Cucumber to work.
Since Cucumber requires JRuby, we’re going to install that, and in order to not disturb any other Ruby development that might be going on on your machine, we are going to isolate it using rvm.
Here’s the rundown:
clone my example repository to give you a clean starting point:
$ git clone https://github.com/luca-ing/cucumber_sikuli.git
$ cd cucumber_sikuli
install rvm:
$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
$ \curl -sSL https://get.rvm.io | bash -s stable --ruby=jruby
install bundler:
$ gem install bundler
install all required gems:
$ bundle
you need to tell cucumber where to find the SikuliX API using an environment variable:
export SIKULIXAPI_JAR=~/projekte/spikes/cucumber-sikuli/sikulixapi.jar
now cucumber should just work.
(nb: I don’t have a Mac, so the test itself fails, but we can see that cucumber runs it correctly)
As you can see Cucumber runs the Sikuli commands (which fail since my system looks differently from what the script expects, but that doesn’t matter).
That’s it — you should now have a working integration between Cucumber and SikuliX.