WinAppDriver – Free Tool To Automate Windows Applications
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
- Download Windows Application Driver
installer from here
- Enable Developer Mode in
Windows settings (shown in below image)
- Run WinAppDriver.exe from the
installation directory (E.g. C:\Program Files (x86)\Windows
Application 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)\Windows Kits\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("http://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
References
·
WinAppDriver GitHub
- GitHub
·
Saravanan
Seenivasan GitHub - Saravanan Seenivasan GitHub
·
Saravanan
Seenivasan YouTube - YouTube
·
WinAppDriver With
WDIO - WinAppDriver-WDIO
Comments
Post a Comment