Inspecting UI Elements for WinAppDriver automation using Appium Desktop
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
Generally speaking, there are three tools could help you with the locators:
- 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”
- 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
- 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
- Goto https://github.com/appium/appium-desktop/releases
- Download the latest release, currently it’s v1.15.0–1
Download and Install WinAppDriver
- Goto https://github.com/microsoft/WinAppDriver/releases
- 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
Then click ‘Start Session’ to launch Calculator App. Then you would see Window like this
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.
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.