App & Browser Testing Made Easy

Give your users a seamless experience by testing on 3000+ real devices and browsers. Don't compromise with emulators and simulators

Home Guide Test Windows Desktop App using Appium-Compatible WinAppDriver

Test Windows Desktop App using Appium-Compatible WinAppDriver

By Apeksha Gupta, Community Contributor -

Table of Contents

While Appium is the most popularly used framework to automate Mobile Apps for Windows, Android, and iOS versions, it is imperative to know that your windows desktop apps too can be automated using an Appium-compatible driver server called WinAppDriver.

This article discusses what WinAppDriver is and how it can be used to automate the testing of Windows Applications.

What is WinAppDriver?

WinAppDriver or WAD is an Appium-compatible WebDriver server that provides automation service for Universal Windows Platform (UWP), Windows Presentation Foundation (UPF), and Classic Windows (Win32) applications. It follows development similar to that of Appium and Selenium. Hence, anybody having knowledge and experience working on these frameworks can easily automate Windows desktop apps using WAD without putting much effort and time into learning it.

Below are some features which make WAD a great tool for choosing your next windows apps automation:

  • It is developed by Microsoft. Hence, it is very stable and provides a rich helping community to help you with any blockers or queries.
  • It can be used directly also without installing Appium to run your scripts as a standalone application alongside using it with Appium.
  • It supports so many majorly used programming languages like Java, Python, Ruby, C#, etc.
  • It can be integrated with CI/CD popular tools like Jenkins, Azure DevOps, and others.
  • It is an open-source tool that can be used for free.

Windows Desktop App Testing using WinAppDriver

Follow the below steps to get started with the first desktop app automation.

Pre-requisites

  • Windows PC with Windows OS version 10 or above.
  • Permissions to use administrator mode.
  • Any development IDE like Eclipse, Visual Studio (2015 version or above), etc.

WinAppDriver Setup and Installation

Step 1: Go to Windows settings and under the For developers menu, turn the developer mode on

Turn Developer Mode on to Test Windows App using WinAppDriver

Step 2:  Download the Windows Application Driver (WinAppDriver) installer

Step 3: Download .msi file and install it on your system

Step 4: Once the installation is completed successfully, go to the following path to run the WinAppDriver exe

C:\Program Files (x86)\Windows Application Driver

Run WinAppDriver exe file after installation

Step 5: Driver will run at port 127.0.0.1:4723 listening to the requests

WinAppDriver running and listening to Requests

Inspecting Elements using WinAppDriver

For doing element inspection for web apps, we can easily right-click on any element and get the required tags by clicking inspect. Since we need to inspect elements for our desktop application too, a tool will be required which can help us with the same. Here, Windows SDK comes to our rescue which does the job very easily and quickly. Also, it is open source and just a click away to download.

Windows SDK configuration

Step 1: Download Windows SDK from the official Microsoft web link. Once the installation is completed on the system, you will get the inspect exe file in the following location:

C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\x64

Windows SDK configuration

Step 2: Open the exe file and you are done with the SDK setup. Start inspecting any desktop app element by just hovering over it.

Inspecting Element on Windows App using WinAppDriver

 

Writing Test Script to Automate Test Windows App

Step 1: Create a new project in Eclipse and configure JDK & TestNG in libraries. The following dependencies need to be added for Appium, Selenium, and TestNG pom.xml file.

<dependencies>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>7.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
</dependencies>

Step 2: Automates the Maps Desktop App on the Windows system to find the route from the current location to the searched destination location using the code written below:

package testing;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.Keys;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.WebDriverWait;
import io.appium.java_client.windows.WindowsDriver;

public class TestMaps {
public WindowsDriver driver = null;
@BeforeMethod
public void setUp(){
DesiredCapabilities cap = new DesiredCapabilities();
//windows application id needs to be given to open the app. Run Get-StartApps in powershell to get all windows app ids.
cap.setCapability("app","Microsoft.WindowsMaps_8wekyb3d8bbwe!App");
//add platformname and device name
cap.setCapability("platformName", "Windows");
cap.setCapability("deviceName", "WindowsPC");

try {
//create webdriver instance
driver = new WindowsDriver(new URL("http://127.0.0.1:4723"), cap);
}
catch (MalformedURLException e) {
e.printStackTrace();
}
//provide implicit wait of 10 seconds
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
@AfterMethod
public void teardown(){
system.out.println(“test run successful”);
}
@Test
public void findofficeroute(){
driver.findElementByName("Search").sendKeys("BrowserStack Mumbai");
driver.findElementByName("Search").sendKeys(Keys.ENTER);
driver.findElementByName("Directions").click();
driver.findElementByName(", My location, ").click(); //Takes user’s current location
driver.findElementByName("Get directions").click();
}
}

Test Result

Test Result of Windows App Test using WinAppDriver

Running the above script successfully on WAD will automate the maps and provide the directions from your current location to the searched destination.

You can easily automate any windows desktop app with the help of WinAppDriver and can hugely reduce efforts in testing your desktop applications manually. Also, you can get expertise in desktop app automation alongside working on web and mobile applications.

In case, one is looking to test their website or apps on different browsers and devices, BrowserStack offers 3000+ real browsers and devices for manual and automation testing. QAs can test Android or iOS apps on thousands of real mobile devices, both latest and legacy. They can integrate seamlessly with the BrowserStack cloud via numerous testing frameworks – AppiumEspressoXCUITest, or EarlGrey.

Testers can execute UI Test automation in order to verify multiple native device features – geolocation testingpush notifications, preloaded images, network simulation, in-app purchase, time zones, languages, etc.

Simply sign up for free, select the device-operating combination required and start testing. The entire process is built to provide convenience, efficiency, speed, and accuracy to testers and developers alike. With a wide range of integrations and debugging tools, BrowserStack is built to not just identify bugs, but to resolve them at the quickest.

Tags
Appium Automation Testing

Featured Articles

Appium with Java: Getting Started to Run Automated Tests

Appium with Python: Getting Started with App Automation Testing

How to Run Browser Compatibility Tests on Windows