Get your Application Audited for Free.

Please fill in the form below to schedule a call or request an estimate.

Sikuli: steps to improve stability and efficiency of automation
single,single-post,postid-15430,single-format-standard,ajax_fade,page_not_loaded,,qode-title-hidden,side_area_uncovered_from_content,qode-content-sidebar-responsive,qode-theme-ver-9.5,wpb-js-composer js-comp-ver-4.11.1,vc_responsive
Fleek IT Solutions : Sikuli stability

Sikuli: steps to improve stability and efficiency of automation

Though, Sikuli have a lot of benefits and features that makes our life easy while developing automation test scripts for desktop apps, there are some cons as well that may affect the efficiency and stability of the test cases developed using Sikuli. One of the major issue that affects the Sikuli’s efficiency is the potential of missing clicks while executing the Sikuli bases test case scripts. Those who are already working with Sikuli framework must already be aware of this issue and might be facing it during the execution of test suites.

Sikuli is one of the most powerful tool for automation testing of GUI based desktop applications. Sikuli can be easily integrated with other programming languages like Python and Java, along with other web based automation testing framework like Selenium Webdriver.

Generic suggestions for making Sikuli scripts more stable

Suggestion 1: Wait():

Use wait() parameters carefully while finding and clicking the elements on GUI. If you are new to the Sikuli scripting, you will be tempted to use the following approach for executing a very simple process :


Here, if your system is busy performing multiple background tasks, there would be a high possibility that Sikuli might go down slow and would be able to find the element and skip the click() action. This possibility can be eliminated by using proper wait() before clicking any element. The most simple approach can be:


Suggestion 2: Use keystrokes instead of clicking

If you can take an action by emulating keystrokes rather than clicks, you’ll save yourself a lot of trouble. For example: instead of clicking a button, you can find the element and send an <Enter> keystroke to the button. This will avoid the possibility of missing a click. Again, this is dependent on application design. If your application does not support clicking a button with Enter keystroke, this approach will be not be of much help.

Suggestion 3: Find alternate methods

Try to find and use alternate method written in more efficient language like Python to do the same action as desired. For example – You may need to write an action in Sikuli to change the system’s date/time. This would require a lots of clicks in Sikuli, which may again affect the efficiency. Now, the same action can be defined with python method in about three lines of code. Again, not all actions can have an alternative method defined in Python, so this solution too its own limitations.

So, now we know that we have some generic suggestions to make our Sikuli test scripts more stable and do what we desire without logging much failures due to missed clicks. But, all these solutions have their own limitations and cannot be used with every area of code which is most error prone. We would need a more stable solution to this problem that can be used almost everywhere and have desired green results. We will be discussing this solution in the next section.

Overriding the generic click() method of Sikuli

To overcome the limitations and restrictions of all above suggested solutions for instability of Sikuli scripts, we have come up with another potential solution. This solution have so far resolved all discussed limitation that we have faced and provides 100% success rate whenever we face any failures due to missing of clicks or delays in Sikuli. By overriding the generic click() method of region class, we will add one additional step to hover over the element first and once hover is successful, then sikuli will click the element. So, now whenever a developer will use the click() method in sikuli, following workflow will take place :

  • Finding the pattern P (element) in defined region R.
  • Hover mouse over element P.
  • Click element P.

What would be the benefit of hovering the mouse over an element before clicking? Sikuli miss the click mostly in cases when you have several background processes running on your system, which may cause the sikuli execution to slow down and as a result sikuli sometimes clicks the element before even the mouse pointer reaches the element. So, this probably leads to a missed click. If we ask Sikuli to hover the element first, and once hover is successful then wait for say 1 second and click the element. This way we will never miss the click and your scripts will execute with 100% success rate without any error from Sikuli side.

How to override generic click() method of region class

So, now as we know that we can override the click() method to avoid missed clicks in Sikuli, question now is, how do we override the generic click() method? If you are using Python as scripting language for your Sikuli scripts, you need to first need to first declare a wrapper region class for the inbuilt generic region class and then override the click method inside the wrapper class. This is how we can achieve it :

Defining a wrapper region class:

class myRegion (Region):
     def __init__(self, origReg):
           self.newReg = origReg
     def click(self, element):

We have defined a new wrapper region class called myRegion and passed an object of original region class as an argument. Defined a new click() method inside the wrapper myRegion which first hovers the element, waits for 1 second and then click the element.

Usage of new click() method:

reg = find(something)

We have defined reg as an object of original region class and find a region using this object. Then this object is passed as an argument to the object of wrapper region class (myReg) and called click() method using myReg which will consecutively call the new click() method.

We hope that the above mentioned solution will help you develop much more stable and efficient Sikuli scripts. Please feel free to contact us by posting comments below.

Fleek IT Solutions
[email protected]

Fleek IT Solutions is a leading independent software testing company specializes in providing unbiased and independent software testing services to global organizations and product companies.

No Comments

Post A Comment