NEWS AND BLOGATAHON2021 BLOGS

WinAppDriver

Blogathon2021

WinAppDriver

By Saravanan Seenivasan

WinAppDriver

WinAppDriver (short for Windows Application Driver) is a free test automation tool for Windows
desktop apps developed by Microsoft. It can run as a standalone as well as
a plugin for Appium. Thus, if you are already running Appium’s server, then a
request for Win10 app automation will launch WinAppDriver.exe, one of the
fast-growing tools that will provide you with better support for using Appium
to test Windows apps.

Appium is cross-platform it allows you to write tests against multiple platforms (iOS,
Android, Windows), using the same API. This enables code reuse between iOS,
Android, and Windows test suites.

 


Supported Applications

It is supported on machines running Windows 10 operating system
(Home and Pro) and Windows Server 2016, and it supports all Windows applications based on:

Universal Windows Platform (UWP)Windows Forms (WinForms)Windows
Presentation Foundation (WPF)
, and Classic Windows (Win32) apps

Configurations

1.     DownloadWindows Application Driver installer from here

2.    Enable Developer Mode in Windows settings (shown in below image)

3.    Run WinAppDriver.exe from the installation directory (E.g. C:\Program Files (x86)\WindowsApplication Driver) Windows Application Driver will then be running on the test machine listening to requests on the default IP address and port (127.0.0.1:4723). 

 


 

Inspect a Windows UI Element

 To start inspecting a windows UI element, we need the Windows kit which can be downloaded from here

The latest version of Microsoft’s Visual Studio includes the Windows SDK by default along with the Inspect tool to inspect the application under test. This tool shows every UI element/node which can be queried using the Windows Application Driver. 

 The inspect.exe tool can be found under the Windows SDK folder which is typically

C:\Program Files (x86)\WindowsKits\10\bin\10.0.19041.0\x64

 In this example, I am inspecting the elements of the Alarms & Clock application

 


 

Note: An alternate of inspect.exe we can use the UiSpy from here – Download UiSpy

Writing the Script

With WinAppDriver you can use any of the following languages C#, Java, JavaScript, Python, Ruby In this example, I’ve to use Java with TestNG. Below is the code I used to launch the session to the Calculator application

Note:
Make sure the winappdriver.exe is running, once the connection is established you can see all the comminutions in winappdriver.exe console

 
      @Test

      public void launchCalculator() throws MalformedURLException
            {

DesiredCapabilities
capabilities = new DesiredCapabilities();

capabilities.setCapability(“app”,”Microsoft.WindowsCalculator_8wekyb3d8bbwe!App”);

capabilities.setCapability(“platformName”,
“Windows”);

capabilities.setCapability(“deviceName”,
“WindowsPC”);

CalculatorSession = new WindowsDriver(new URL(“https://127.0.0.1:4723”),
capabilities);

CalculatorSession.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);

}

 Locators

Windows Application Driver supports various locators to find UI element in the application session. The table below shows all supported locator strategies with their corresponding UI element attributes shown in inspect.exe

 


 

Supported Capabilities

Below are the capabilities that can be used to create Windows Application Driver session

 


Comparison

Winium – deprecated. Though it is deprecated, we could use it for our solution. But future enhancements in AUT might not be supported by Winium. So, we might need to re-form team or migrate to other frameworks.

Tricentis Tosca– Supports .NET, Java, Web and Mobile applications. Since our application is developed using WPF, I preferred other tools. Reporting options are limited in Tosca.

Micro Focus UFT
Though it is on top priority when it comes to Windows Application Test Automation, it does have some disadvantages to look for. UFT supports only VB Script as development programming language. Training and adoption to this tool required little more time and effort. With team of C# and Java, we would need to upskill or re-structure our team to proceed with this tool. Integration of our libraries for other requirements seemed more complex.

SikuliX – Since it is image-based automation tool, Execution would be slower and more fragile.

WhiteFramework– deprecated. Like Winium, White Framework might not support future enhancements of windows application.

References

     WinAppDriver GitHub – GitHub 

     Saravanan Seenivasan GitHub – Saravanan Seenivasan GitHub

     Saravanan Seenivasan YouTube – YouTube

 

About Author

Saravanan Seenivasan

Overall 10 years of experience where 7 years in Automation Testing and 3 Years of Experience in Operations and Implementations.

Experienced in below Skills, Technologies and Tools in Software Testing:

Programming Language: Java & Basics in Java Script

Specialization: Selenium WebDriver, Cucumber, TestNG, WinAppDriver (Appium), WebdriverIO, Cypress, SpecFlow

API Testing: Rest-Assured & Postman Scripts

Performance Testing: Jmeter

RPA Skills: RPA-UiPath

Database: Sql Server, MySql, NoSql

Build Management: Maven, Jenkins, Azure Devops

Source Code Management: GitHub, Git

Code Coverage Tool – SonarQube and Whit source

Test Management Tools: Azure – VSTS

Integrated Development Environment: Eclipse, VS Code

Tools: Postman, UiPath, Jmeter

GitHub Reference:
https://github.com/sseenivasan89

YouTube Channel:
https://www.youtube.com/c/SaravananSeenivasan

Leave a Comment