You are viewing our old blog site. For latest posts, please visit us at the new space. Follow our publication there to stay updated with tech articles, tutorials, events & more.

Sikuli – Adding power to Selenium

0.00 avg. rating (0% score) - 0 votes
Selenium WebDriver is a tool for writing automated tests of websites. It aims to mimic the behavior of a real user, and as such interacts with the HTML of the application. (source: code.google.com [https://code.google.com/p/selenium/wiki/FrequentlyAskedQuestions#Q:_What_is_WebDriver_?]).
However in test cases where we need to interact with elements outside of the webpage WebDriver becomes powerless. One such test we encountered was:
Clicking on a button in the browser window sidebar
1)   Start FireFox
2)   Navigate to an URL
3)   Start SQL inject-me addon
4)   Click on the “Test all forms with SQL injection” button in the browser window sidebar
As you would notice step 4 requires clicking a button outside of the webpage which is not possible with WebDriver. So we came up with a work-around [http://www.macmillandictionary.com/open-dictionary/entries/jugad.htm] and used Sikuli to automate step 4.
Sikuli is an automation tool that uses image recognition to identify and control GUI components (source: http://www.sikuli.org/[https://code.google.com/p/selenium/wiki/FrequentlyAskedQuestions#Q:_What_is_WebDriver_?]).
You might question why we did not use Sikuli to automate the whole test instead of using it with WebDriver. Well, we already have an automation suite and we wanted to integrate testing SQL injection attacks into it.
Selenium WebDriver and Sikuli both have a java based engine and hence compatible and together provide a powerful combination for automated website testing.
Some other test case examples where this combination can be used successfully are:
1)   Bookmarking a page
2)   Clicking on a link in the toolbar
3)   Clicking on a quick link in the browser window

To drive Sikuli through selenium we need to do is add sikuli-script.jar [https://www.assembla.com/code/plus/subversion/nodes/trunk/PlusLib/tools/Sikuli/sikuli-script.jar?rev=1952] to the build path, import org.sikuli.script.FindFailed, org.sikuli.script.Pattern, org.sikuli.script.Screen to our class file and Voilà we are done.

The following is the code for launching SQL Inject-Me (a firefox addon for testing web pages for SQL injection vulnerabilities) in Firefox
Posted in General