Most Complete WinAppDriver C# Cheat Sheet

Most Complete WinAppDriver C# Cheat Sheet

The next article from the desktop automation series will be dedicated to WinAppDriver.

WinAppDriver is a service to support Selenium-like UI Test Automation on Windows Applications. This service supports testing Universal Windows Platform (UWP)Windows Forms (WinForms)Windows Presentation Foundation (WPF), and Classic Windows (Win32) apps on Windows 10 PCs.

Download  WinAppDriver C# Cheat Sheet PDF

Initialize

// NuGet: Appium.WebDriver
var appiumOptions = new AppiumOptions();
appiumOptions.AdditionalCapability("app", "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App"); // for Universal Windows Platform apps
appiumOptions.AdditionalCapability("app", "C:\Windows\System32\notepad.exe"); // for classic Windows apps
appiumOptions.AdditionalCapability("deviceName", "WindowsPC");
_driver = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), options);
_driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);

Locators

driver.FindElementById("42.333896.3.1");
_driver.FindElementByAccessibilityId("AppNameTitle");
_driver.FindElementByClassName("TextBlock");
_driver.FindElementByWindowsUIAutomation("Views");
_driver.FindElementByName("Calculator");
_driver.FindElementByTagName("Text");
// Find multiple elements
_driver.FindElementsByClassName("TextBlock");
// Search for an element inside another element
_driver.FindElementByName("System")
.FindElementByName("Minimize");

Basic Interactions & Actions

// Simple actions
element.Click();
element.SendKeys("textToType");
element.Clear();
// Chained actions
Actions actions = new Actions(_driver);
actions.MoveToElement(element);
actions.MoveByOffset(x, y);
actions.Click();
actions.ClickAndHold();
actions.Release();
actions.ContextClick();
actions.DoubleClick();
actions.DragAndDrop(sourceElement, targetElement);
actions.DragAndDropToOffset(sourceElement, x, y);
actions.KeyDown(Keys.Shift);
actions.KeyUp();
actions.SendKeys("textToType");
actions.Build().Perform();
// Take screenshot
_driver.GetScreenshot(); // returns Screenshot (base64 encoded PNG)

Touch & Pen Interactions

// Making a touch stroke
PointerInputDevice device = new PointerInputDevice(PointerKind.Touch);
ActionSequence sequence = new ActionSequence(penDevice, 0);
sequence.AddAction(device.CreatePointerMove(element, 0, 0, TimeSpan.Zero));
sequence.AddAction(device.CreatePointerDown(PointerButton.TouchContact));
sequence.AddAction(device.CreatePointerMove(element, 10, 10, TimeSpan.Zero));
sequence.AddAction(device.CreatePointerUp(PointerButton.TouchContact));
_driver.PerformActions(new List<ActionSequence> { sequence });
// Perform multitouch
PointerInputDevice touch1 = new PointerInputDevice(PointerKind.Touch);
ActionSequence touch1Sequence = new ActionSequence(touch1, 0);
touch1Sequence.AddAction(touch1.CreatePointerMove(element, 50, -50, TimeSpan.Zero));
touch1Sequence.AddAction(touch1.CreatePointerDown(PointerButton.TouchContact));
touch1Sequence.AddAction(touch1.CreatePointerMove(element, 80, -80,
TimeSpan.FromSeconds(1)));
touch1Sequence.AddAction(touch1.CreatePointerUp(PointerButton.TouchContact));
PointerInputDevice touch2 = new PointerInputDevice(PointerKind.Touch);
ActionSequence touch2Sequence = new ActionSequence(touch2, 0);
touch2Sequence.AddAction(touch2.CreatePointerMove(element, -50, 50, TimeSpan.Zero));
touch2Sequence.AddAction(touch2.CreatePointerDown(PointerButton.TouchContact));
touch2Sequence.AddAction(touch2.CreatePointerMove(element, -80, 80,
TimeSpan.FromSeconds(1)));
touch2Sequence.AddAction(touch2.CreatePointerUp(PointerButton.TouchContact));
_driver.PerformActions(new List<ActionSequence> { touch1Sequence, touch2Sequence });
// Pen actions and options
PointerInputDevice device = new PointerInputDevice(PointerKind.Pen);
ActionSequence sequence = new ActionSequence(device, 0);
PenInfo penExtraAttributes = new PenInfo { TiltX = 45, TiltY = 45, Twist = 45 };
sequence.AddAction(device.CreatePointerMove(element, 0, 0, TimeSpan.Zero));
sequence.AddAction(device.CreatePointerDown(PointerButton.PenContact,
 penExtraAttributes));
sequence.AddAction(device.CreatePointerMove(element, 10, 10, TimeSpan.Zero, new
PenInfo { Pressure = 1f }));
sequence.AddAction(device.CreatePointerUp(PointerButton.PenContact));
_driver.PerformActions(new List<ActionSequence> { sequence });

Download  WinAppDriver C# Cheat Sheet PDF

Related Articles

Desktop Automation, Web Automation

Automate Windows Desktop Apps with WebDriver- WinAppDriver C#

In the Desktop Automation Series, you can find invaluable tips and tricks about desktop automation. I will dedicate the next couple of articles on the automatio

Automate Windows Desktop Apps with WebDriver- WinAppDriver C#

Resources, Web Automation Java

Most Complete Selenium WebDriver Java Cheat Sheet

As you know, I am a big fan of Selenium WebDriver. You can find tonnes of useful Java code in my Web Automation Java Series. I lead automated testing courses an

Most Complete Selenium WebDriver Java Cheat Sheet

Resources, Web Automation

Most Exhaustive WebDriver Locators Cheat Sheet

As you know, I am keen on every kind of automation especially related to web technologies. So, I enjoy using Selenium WebDriver. You can find lots of materials

Most Exhaustive WebDriver Locators Cheat Sheet

Mobile Automation, Resources

Most Complete Appium C# Cheat Sheet

The next article from the mobile test automation series will be dedicated to Appium. All you need to to know – from the most basic operations to the most advanc

Most Complete Appium C# Cheat Sheet

Resources, Web Automation

Most Complete Selenium WebDriver C# Cheat Sheet

As you know, I am a big fan of Selenium WebDriver. You can find tonnes of useful code in my WebDriver Series. I lead automated testing courses and train people

Most Complete Selenium WebDriver C# Cheat Sheet

Desktop Automation

Windows WebDriver- WinAppDriver- Page Objects C#

In the last article from the Desktop Automation Series, I showed you how you could automate Windows desktop apps through WinAppDriver. A framework developed by

Windows WebDriver- WinAppDriver- Page Objects C#
Anton Angelov

About the author

Anton Angelov is Managing Director, Co-Founder, and Chief Test Automation Architect at Automate The Planet — a boutique consulting firm specializing in AI-augmented test automation strategy, implementation, and enablement. He is the creator of BELLATRIX, a cross-platform framework for web, mobile, desktop, and API testing, and the author of 8 bestselling books on test automation. A speaker at 60+ international conferences and researcher in AI-driven testing and LLM-based automation, he has been recognized as QA of the Decade and Webit Changemaker 2025.