Reading Time : 0 Mins

Winium – A Step-By-Step Guide

In today’s technology trend, every software application we use is made available either as a web application or mobile app. But there are lots of desktop applications still in use in large enterprises. To test these windows based applications we still largely rely on commercial tools like TestComplete, HP Unified Functional Tester, Coded UI, etc. With the rise in open source testing tools, we have seen tools like AutoIT, Sikuli coming up.

In this article, we would like to talk about a lesser-known open source testing tool for windows automation – Winium

Winium is an automation framework for windows platform. It is a free and open source tool based on Selenium.

Selenium, the widely used open source tool for the web application, provides support for Mobile Applications using Appium. Earlier for Window Application automation, we had used some external tools like Sikuli, AutoIT etc. Now we have Winium to go with the Selenium bag.

Winium Supported Platforms:

  • Windows Desktop (WPF, WinForms) Apps,
  • Windows Store or Universal Apps for Windows Phone,
  • Windows Phone Silverlight Apps

Winium Supported Languages:

  • Java
  • Objective-C
  • JavaScript with Node.js
  • PHP
  • Python
  • Ruby
  • C#
  • Clojure, or Perl with the Selenium WebDriver API

Winium Test Framework:

  • JUnit
  • TestNG
  • PyUnit
  • NUnit

Working with Winium is pretty simple and easy if you already have experience with Selenium. In Selenium, for the web application, we use FireBug or FirePath to identify the element locators. Similarly, in Winium we can UISpy.exe or Inspect.exe (available by default in windows) to identify the element locators in Windows application.

Prerequisites to work with Winium:

  • Microsoft .NET Framework
  • Download Latest Eclipse
  • Create Maven Project
  • Download UISpy

Software Applications Development

Steps To Do:

Step 1: Add below dependency in pom.xml

    com.github.2gis.winium

    winium-webdriver

    0.1.0-1

You can also download the dependency from below link:

https://mvnrepository.com/artifact/com.github.2gis.winium/winium-webdriver

Step 2: Download Winium.Desktop.Driver.exe.

https://github.com/2gis/Winium.Desktop/releases

Step 3: Once downloaded, launch the driver, it will open by default with port 9999 which acts as a server.

Internally this server will communicate through JSON Wireless Protocol

Step 4: Add TestNG dependency to run an application

org.testng

testng

6.14.3

test

Step 5: Create a sample Java Project and a class and use the below code to automate calculator

package com.winium.demo;

import java.net.MalformedURLException;

import java.net.URL;

import org.openqa.selenium.By;

import org.openqa.selenium.winium.DesktopOptions;

import org.openqa.selenium.winium.WiniumDriver;

public class Calculator {

public static void main(String[] args) throws MalformedURLException, InterruptedException {

DesktopOptions option = new DesktopOptions();

option.setApplicationPath(“C:\Windows\System32\calc.exe”);

WiniumDriver driver = new WiniumDriver(new URL(“https://localhost:9999”), option);

Thread.sleep(5000);

driver.findElement(By.name(“One”)).click();

driver.findElement(By.name(“Plus”)).click();

driver.findElement(By.name(“Two”)).click();

driver.findElement(By.name(“Equals”)).click();

String output = diver.findElement(By.id(“CalculatorResults”)).getAttribute(“Name”);

System.out.println(“Result after addition is: “+output);

driver.quit();

}}

Winium seems to be quite promising for windows application automation. Even though it is in a nascent stage if the application test supports different platforms like web, mobile (ios, android, windows), windows desktop then Selenium + Appium + Winium will be a winning combination.

What do you think?

Keerthika
Keerthi Veerappan

An INFJ personality wielding brevity in speech and writing. Marketer @ Zucisystems.

Share This Blog, Choose Your Platform!

Leave A Comment

Related Posts