A practical FlaUI tutorial for C# testers: UIA2 vs UIA3, FlaUInspect, a first NUnit test, stable locators and waits, CI setup, and FlaUI vs WinAppDriver.
FlaUI is an open-source .NET library for automating Windows desktop applications through Microsoft UI Automation. It gives C# teams a clean API over UIA2 and UIA3, so you can find controls, click, type, and read values from WinForms, WPF, UWP, and Win32 apps, then assert on them in NUnit, xUnit, or MSTest.
This FlaUI tutorial covers choosing between UIA2 and UIA3, installing the packages, inspecting your app with FlaUInspect, writing a first test, finding elements reliably, waiting without sleeps, and running the suite in CI. It also compares FlaUI with WinAppDriver and explains how FlaUI fits with Robot Framework and Katalon Studio.
What is FlaUI?
FlaUI is a C# library, released under the MIT license, that wraps Microsoft's UI Automation APIs. UI Automation is the accessibility layer Windows uses to expose controls to screen readers, and it is what almost every Windows UI testing tool uses underneath. FlaUI makes that layer pleasant to use from .NET.
The project is actively maintained. Version 5.0.0 was released in February 2025. It is also the engine behind other tools: Robot Framework's FlaUILibrary and Katalon Studio's built-in Windows driver both use it.
FlaUI is a good fit when:
- Your team writes C# and wants Windows UI tests next to its unit and integration tests.
- You want direct access to UI Automation patterns without a WebDriver server in between.
- You are replacing WinAppDriver and are willing to rewrite rather than port.
UIA2 vs UIA3: which should you use?
FlaUI supports both versions of Microsoft UI Automation through separate packages.
UIA2 ( | UIA3 ( | |
|---|---|---|
Based on | Managed UIA API (.NET) | Native COM UIA API |
Best for | WinForms apps, especially older ones | WPF, UWP, and most modern apps |
Default choice | Fall back to it if UIA3 misses controls | Start here |
Start with UIA3. If WinForms controls are missing or report the wrong properties, try UIA2 for that app. Do not mix both in the same test run.
How to install FlaUI
Create a test project and add the packages. With NUnit:
dotnet new nunit -n DesktopTests
cd DesktopTests
dotnet add package FlaUI.UIA3FlaUI.UIA3 brings in FlaUI.Core as a dependency. Use FlaUI.UIA2 instead if you chose UIA2. The test project must target Windows, so set your target framework to a Windows variant such as net8.0-windows if the build complains.
Inspect your app with FlaUInspect
FlaUInspect is a companion tool from the same project that shows the UI Automation tree of any running app. Hover or click a control to see its AutomationId, name, class name, and control type. You can get it from the FlaUInspect repository on GitHub. Accessibility Insights for Windows and Inspect.exe from the Windows SDK show the same information.
Prefer locators in this order: AutomationId, then name plus control type, then class name, then XPath. AutomationIds survive text changes and translations. If key controls have none, ask the developers to add them. It is usually a small change and the single biggest stability gain in desktop testing.
Your first FlaUI test
This NUnit test launches an app, logs in, and checks the welcome message. Replace the path and AutomationIds with your own from FlaUInspect.
using System;
using FlaUI.Core;
using FlaUI.Core.AutomationElements;
using FlaUI.Core.Tools;
using FlaUI.UIA3;
using NUnit.Framework;
public class LoginTests
{
private Application _app;
private UIA3Automation _automation;
private Window _window;
[SetUp]
public void SetUp()
{
_app = Application.Launch(@"C:\Path\To\YourApp.exe");
_automation = new UIA3Automation();
_window = _app.GetMainWindow(_automation, TimeSpan.FromSeconds(10));
}
[Test]
public void LoginShowsWelcomeMessage()
{
var cf = _automation.ConditionFactory;
_window.FindFirstDescendant(cf.ByAutomationId("UsernameTextBox")).AsTextBox().Enter("qa.user");
_window.FindFirstDescendant(cf.ByAutomationId("LoginButton")).AsButton().Invoke();
var welcome = Retry.WhileNull(
() => _window.FindFirstDescendant(cf.ByAutomationId("WelcomeLabel")),
TimeSpan.FromSeconds(10)).Result;
Assert.That(welcome.AsLabel().Text, Does.Contain("qa.user"));
}
[TearDown]
public void TearDown()
{
_app.Close();
_automation.Dispose();
}
}What is happening here:
Application.Launchstarts the process. UseApplication.Attachinstead if the app is already running or launches through a separate process.GetMainWindowwaits up to the timeout for the main window to appear.ConditionFactorybuilds search conditions.ByAutomationId,ByName,ByControlType, andByClassNamecover most needs.As...()converts a generic element into a typed one (AsTextBox,AsButton,AsLabel,AsComboBox, and so on) with the right methods.Retry.WhileNullpolls until the element exists or the timeout passes.
Finding elements reliably
A few patterns keep FlaUI tests stable:
var cf = _automation.ConditionFactory;
// Combine conditions when a name alone is not unique
var saveButton = _window.FindFirstDescendant(
cf.ByName("Save").And(cf.ByControlType(FlaUI.Core.Definitions.ControlType.Button)));
// Search inside a known container instead of the whole window
var grid = _window.FindFirstDescendant(cf.ByAutomationId("OrdersGrid")).AsGrid();
var firstRow = grid.Rows[0];
// XPath works too, but keep it short and relative
var okButton = _window.FindFirstByXPath("//Button[@Name='OK']");Searching from a container rather than the window root is faster and less likely to match the wrong element. Use XPath sparingly: long absolute paths break as soon as the layout changes.
Waiting without sleeps
Fixed Thread.Sleep calls make desktop suites slow and flaky. FlaUI's Retry class polls instead:
// Wait for an element to appear
var dialog = Retry.WhileNull(
() => _window.FindFirstDescendant(cf.ByAutomationId("ConfirmDialog")),
TimeSpan.FromSeconds(10)).Result;
// Wait for a condition to become true
Retry.WhileFalse(
() => _window.FindFirstDescendant(cf.ByAutomationId("SaveButton")).IsEnabled,
TimeSpan.FromSeconds(5));Set throwOnTimeout: true on these calls when you want the test to fail at the wait rather than on a later null reference. It makes failure messages much easier to read.
Screenshots on failure
FlaUI includes a capture API you can call from a teardown when a test fails:
using FlaUI.Core.Capturing;
Capture.Screen().ToFile(@"C:\TestResults\failure.png");You can also capture a single element, such as the main window, with Capture.Element(_window). Attach the file to your test result so CI shows it next to the failure.
Running FlaUI tests in CI
FlaUI drives a real desktop, so your CI agent needs one:
- Run the agent as a logged-in user with an unlocked screen. UI Automation cannot reach apps on a locked or disconnected session. A Windows service account will not work.
- Use a dedicated Windows VM with a fixed resolution and the app's prerequisites installed.
- Run tests in sequence by default. Desktop tests share one screen and one input focus, so parallel runs on the same machine collide.
- Publish results with your test runner's standard output, for example
dotnet test --logger trx, so your CI server tracks history.
FlaUI vs WinAppDriver
Many teams find FlaUI while looking for a WinAppDriver replacement.
FlaUI | WinAppDriver | |
|---|---|---|
Maintenance | Active, 5.0.0 released February 2025 | Unmaintained, last release 2020 |
Architecture | In-process .NET library | Separate WebDriver server |
Languages | C# and other .NET languages | Any WebDriver client |
UIA versions | Choose UIA2 or UIA3 | Fixed, not configurable |
Setup | NuGet package | Installer, Developer Mode, running service |
Recorder | No (FlaUInspect inspects only) | UI Recorder, also unmaintained |
Locators carry over directly, because both read the same UI Automation properties. For a step-by-step migration plan and other options, see WinAppDriver alternatives and how to migrate.
FlaUI with Robot Framework
If your team prefers keyword-driven tests, FlaUILibrary brings FlaUI into Robot Framework. You write tests as readable keyword tables while FlaUI does the UI Automation work underneath, and Robot Framework's HTML logs and reports come for free. It is a good middle ground for teams where not everyone writes C#.
FlaUI and Katalon Studio
Katalon Studio's Windows driver, included from version 10.4, is built on FlaUI. That means the same UI Automation approach, packaged with things you would otherwise build yourself:
- A Windows Spy and Recorder for capturing objects and flows.
- Keyword steps and Groovy scripting in the same test.
- Built-in reports with screenshots and logs.
- Command-line runs through Katalon Runtime Engine (KRE) for CI.
- Web, mobile, and API tests in the same project.
The trade-off is cost and flexibility. Desktop testing is part of Studio's paid plans, which start at $1,800 per seat per year, and you work inside Studio's framework rather than your own .NET solution. Teams with strong C# skills and a single Windows app often stay with FlaUI directly. Teams with mixed skills or several app types often find the packaged route cheaper overall. See Katalon desktop testing for details.
FlaUI limitations
- Code only. There is no recorder, reporting, or test management in the library itself.
- Windows only. FlaUI cannot test macOS or Linux desktop apps.
- You own the framework. Page objects, waits, data handling, and CI wiring are code your team writes and maintains.
- Documentation is thin. The project wiki and source are the main references, so expect to read code for edge cases.
For a wider comparison of free and commercial tools, see our guide to desktop automation tools. Python teams should also read our pywinauto tutorial.
Frequently asked questions
FlaUI is an open-source .NET library that wraps Microsoft UI Automation so C# code can find, click, type into, and read controls in Windows desktop apps. It is commonly used for automated UI testing with NUnit, xUnit, or MSTest.
Start with UIA3, which works best for WPF, UWP, and most modern apps. Try UIA2 if WinForms controls are missing or report the wrong properties. Do not mix both in the same test run.
FlaUInspect is a companion tool from the FlaUI project that shows the UI Automation tree of a running app. Use it to find AutomationIds, names, and control types for your locators.
For new C# projects, usually yes. FlaUI is actively maintained, runs in-process with no server to manage, and lets you choose UIA2 or UIA3. WinAppDriver has had no release since 2020, though it supports any WebDriver client language.
Yes. FlaUILibrary brings FlaUI into Robot Framework, so you can write keyword-driven desktop tests and get Robot Framework's HTML logs and reports.
Yes. From version 10.4, Katalon Studio's built-in Windows driver is based on FlaUI, so you no longer need to install WinAppDriver to test Windows desktop apps in Studio.

Test everything. Ship with confidence.
From generating test cases to spotting failures, Katalon's AI works across your entire pipeline, automatically.




