Inspecting UI Elements for WinAppDriver automation using Appium Desktop

Canhua Li
3 min readOct 16, 2019

--

Windows Application Driver(WinAppDriver) is the recommended tool to do UI automation for Windows applications. WinAppDriver supports various locators to find UI element, and then drive then to perform actions, below table shows all the supported locators

WinAppDriver supported locators

Generally speaking, there are three tools could help you with the locators:

  1. Inspect.exe. This is shipped together with Visual studio and it’s inside the SDK directory like this: “C:\Program Files (x86)\Windows Kits\10\bin\10.0.16299.0\x64\inspect.exe”
  2. UI Recorder. standalone tool that aims to provide users a simpler way of creating automaton scripts by recording UI events performed by the user and generating XPath queries and C# code on the fly
  3. Appium Desktop App. It’s a graphical interface for Appium server, also an inspector that help you to look at application’s element.

Here I only talk about how to locate the element using Appium desktop

Download and Install Appium Desktop

  1. Goto https://github.com/appium/appium-desktop/releases
  2. Download the latest release, currently it’s v1.15.0–1

Download and Install WinAppDriver

  1. Goto https://github.com/microsoft/WinAppDriver/releases
  2. Download the latest release, currently it’s v1.1

Note: The relationship between WinAppDriver and Appium is hard coded. You may see logs like ‘You must use WinAppDriver version v1.1’ in Appium log if a mismatched version of WinAppDriver is used. You may go back to ‘The Server is running’ to check which WinAppDriver you should install. Like below, it’s asking 1.1

Use Appium Desktop to Launch Test Application

After Appium is launched, click Start Server, and a new Window is popped up and it showed: ‘The server is running’

Open New Session Window

Fill Capabilities, and below is capabilities to launch Calculator

{
"platformName": "windows",
"deviceName": "WindowsPC",
"app": "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App"
}

Then click ‘Start Session’ to launch Calculator App. Then you would see Window like this

Inspect Element

Click ‘Select Elements’, then select the element you are interested in, here I selected ‘5’. In ‘Selected Element’ page on the right side, it includes AutomationId, ClassName, LocalizedControlType, Name, XPath for ‘5’, and that’s what we expect to use in the test case.

Interactive Search

Appium desktop also supports interactive search, just like you are working on CLI. Click ‘Search for element’, then select Locator Strategy like ‘XPath’, and Input selector ‘//Button’ to select all Buttons. Then click search

A search result window would show up, you can click element like 42.987984.4.38 in the search result, then ‘X’ in Calculator is highlighted.

--

--