Sikuli Using Selenium In C#

Sikuli is a scripting language to automate the Web Application or desktop Application by using screenshots or the images of the Webpage or to control screenshots. It is Python based scripting to write visual automation scripts for automating Browser or desktop based Applications.

Sikuli was an open-source research project at the User Interface Design Group at MIT.

Sikuli is an automation tool, which is used to automate anything which you see on the screen or graphical user Interface (GUI). It's built using an Image Recognition algorithm to identify the controls on the Webpage or desktop Application. It is a bit similar to the Selenium automation tool, where we can identify a control in Selenum by its control properties like its Id, Tagname, Xpath, CSS Selector, Control name etc. But in such scenarios, if there are no control properties given for a control, we can use Sikuli to identify the control by its image.

You can learn how to automate Sikuli for desktop Application from Sikuli's official Website: http://www.sikuli.org/
Sikuli can be developed using various technologies or languages like,
  • .NET technologies(C# and .NET)
  • Java technologies
  • Javascript
  • Ruby etc.
If we are developing Sikuli, using C# and .NET, Sikuli provides three different class libraries or APIs such as
  • Sikuli Integrator (or) Sikuli Module
  • Sikuli Sharp
  • Sikuli4Net, which can be downloaded from nuget packages.
Among this three class Libraries; the most commonly used is Sikuli4Net, which provides various classes and methods to use it. It uses Java Runtime Environment (JRE) to execute the Sikuli scripts.

Follow the link to automate desktop Applications http://nadimsaker.blogspot.in/2015/02/sikuli-how-to-install-and-run-sikuli-in.html

Follow this link to automate Web Applications https://sourceforge.net/projects/sikuli4net/
 
Following are the DLLl's required to run Sikuli, using Selenium in C#,
  1. Sikuli4Net DLL can be downloaded from NuGet packages.
  2. Newtonsoft.json can be downloaded from NuGet packages.
  3. Selenium webdriver can be downloaded from NuGet packages.
  4. Webdriver.Support can also be downloaded from NuGet packages. 
  5. sikulirestapi-1.0.jar can be downloaded and placed into Unit testing class library solution.
Code to understand Sikuli, using Selenium in C# is given below.
  1. Using OpenQA.Selenium;  
  2. Using OpenQA.Selenium.Chrome;  
  3. Using MbUnit.Framework;  
  4. Using Sikuli4Net.Sikuli_REST;  
  5. Using Sikuli4Net.Sikuli_JSON;  
  6. Using Sikuli4Net.Sikuli_UTIL;  
  7. [TestClass]  
  8. [TestFixture]  
  9. Public class SikuliTest {  
  10.     APILauncher launch = new APILauncher(true);  
  11.     Pattern Image1 = new Pattern("D:/>SikuliImages/SignupClick.png");  
  12.     Pattern Image2 = new Pattern("D:/>SikuliImages/FirstName.png");  
  13.     Pattern Image3 = new Pattern("D:/>SikuliImages/LastName.png");  
  14.     Pattern Image4 = new Pattern("D:/>SikuliImages/Email.png");  
  15.     Pattern Image5 = new Pattern("D:/>SikuliImages/Password.png");  
  16.     [TestMethod]  
  17.     Public void SikuliTestingMethod() {  
  18.         Launch.Start();  
  19.         IwebDriver driver = new ChromeDriver("D:/>SeleniumDrivers/ChromeDriver32");  
  20.         driver.Manage().Window.Maximize();  
  21.         driver.Navigate.GoToURL("http://www.csharpcorner.com/");  
  22.         Screen scr = new Screen();  
  23.         scr.Click(Image1, true);  
  24.         scr.wait(10);  
  25.         scr.Type(Image2, "string to Enter", KeyModifier.None);  
  26.         scr.wait(10);  
  27.         scr.Type(Image3, "string to enter", keyModifier.None);  
  28.         scr.wait(10);  
  29.         scr.Type(Image4, "string to enter", KeyModifier.None);  
  30.         scr.wait(10);  
  31.         scr.Type(Image5, "string to enter", KeyModifier.None);  
  32.         scr.wait(10);  
  33.         driver.quit();  
  34.     }  
  35. }  
Thanks for reading the blog. I hope this helps.
Ebook Download
View all
Learn
View all