Windows application automation using WinAppDriver


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.

Leave A Comment

Your email address will not be published. Required fields are marked *