Tech Blog

Testing

Windows application automation using WinAppDriver

By Sarthak Panda3 min read
← Back to blog

Getting Started 

Windows Automation driver is a tool that Microsoft provides to automate Windows desktop apps. It helps to automate different types of Windows applications including Windows Forms (WinForms), Windows Presentation Foundation (WPF), Universal Windows Platform (UWP) and Classic Windows (Win32) apps on the Windows 10 operating system.In appearance and feel, this tool is identical to Selenium WebDriver and can easily be included within the Selenium WebDriver testing framework.

Prerequisites to setup windows application automation 

  • Windows 10 OS
  • Windows 10 SDK and  “Inspect.exe” 
  • Windows application driver: The Windows application driver must be installed on the device.You can download it from the website below.
https://github.com/microsoft/WinAppDriver/releases/tag/v1.1

Install and Configure Windows Application driver 

1.Install the WinAppDriver application on your laptop

2.Then enable developer mode from the below location

Settings >> update and security >> For Developers >> Developer mode

3.Go to win app driver installed location and run the winappdriver.exe file as an administrator.file location is given below .

Winappdriver.exe location : C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe

4.win app server  runs as a server on a specific IP address and port. By default, it’s http://127.0.0.1:4723, and that’s what we will use in our tests.Start the WinAppDriver session and minimize it.

How to locate windows application elements using Inspect.exe 

Windows application elements can be located using the inspect element tool which can be found under the Windows SDK folder in the below location .

Inspect tool location : C:\Program Files (x86)\Windows  Kits\10\bin\10.0.17763.0\x86\inspect.exe

Example :Inspecting element by keeping the mouse pointer on the element in the application .

Note:If windows SDK is not available in the device then it can be downloaded from below location .

https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk

Locators:The elements in the application can be located using attributes like ID, name, xpath and accessibility ID. The preferred way to automate the application is by using the accessibility ID / Automation ID. 

Steps to automate test case :

1.Launch Eclipse

2.Create a  new Maven project 

3. In the pom.xml file add selenium , appium and TestNg dependencies .

4. Once the setup is completed, find the sample code to automate the test case  

      1. Open “Notepad”

      2. Open “Help” menu item

      3. Press “About Notepad”

Conclusion :

Microsoft’s WinAppDriver is a great open-source tool. Besides handling many features, one drawback that I found was that while running the script a background application or laptop lock can cause the script to fail. Please keep this in mind when running the script. Hopefully this article will provide a basic overview of WinAppDriver.

Keep reading

You may be interested in

Browse all articles →
Software Testing: Challenges and Solutions
February 8, 20244 min read

Software Testing: Challenges and Solutions

Introduction – Testing software is a crucial aspect of the development process. It makes sure that the product’s functionality works as expected, fulfills the user requirements, and makes sure it works without errors. In this blog, we will list down some of the most common challenges faced in software testing and conclude with how to […]

By Saboor ChandshahaRead More →
Streamlining Software Quality: The Power of Automating Black Box Testing
February 8, 20244 min read

Streamlining Software Quality: The Power of Automating Black Box Testing

Introduction :  In the dynamic realm of software development, ensuring the robustness and reliability of applications is of paramount importance. Black box testing, a technique that assesses software functionality without requiring knowledge of its internal code, plays a vital role in identifying potential defects. As the complexity of software systems continues to escalate, the manual […]

By Anthony Gilchrist G SRead More →
Implementing best practices for end-to-end testing in cloud migration
January 31, 20245 min read

Implementing best practices for end-to-end testing in cloud migration

Importance of End-to-End Testing Assume an organization’s core systems are now hosted on the cloud—a complex ecosystem linked by data threads. End-to-end testing is the foundation upon which the reliability and performance of this interconnected web is built. This rigorous testing technique makes it possible to detect vulnerabilities, optimize operations, and improve user experience. Active […]

By Rahul ChakravartiRead More →