Testland
Browse all skills & agents

flaui-tests

Authors and runs FlaUI-based Windows UI tests - the .NET-native wrapper around Microsoft UI Automation (UIA2 + UIA3). Covers the `FlaUI.Core` / `FlaUI.UIA2` / `FlaUI.UIA3` NuGet packages, `Application.Launch` / `Application.Attach` lifecycles, `ConditionFactory` + `FindFirstDescendant` locator patterns, `Retry` waits, and xUnit / NUnit / MSTest harness integration. Use when the test stack is C# / .NET-first and the team wants idiomatic in-process UIA calls rather than the HTTP/JSON wire protocol of `winappdriver` or the Appium proxy layer of `appium-windows-driver`.

Install with skills.sh (any agent)

npx skills add testland/qa --skill flaui-tests
View source

flaui-tests

Overview

FlaUI is a .NET library for automated UI testing of Windows applications (flaui (opens in new window)) that wraps Microsoft UI Automation (UIA) - the Windows accessibility tree covered in desktop-test-strategy-reference - behind an idiomatic C# API. It supports "Win32, WinForms, WPF, and Store Apps" via two bindings: UIA2 (managed System.Windows.Automation, Microsoft Learn - UI Automation Overview (opens in new window)) and UIA3 (COM interop). v5.0.0 released February 2025; MIT-licensed and actively maintained (flaui (opens in new window)).

Disambiguation - FlaUI vs winappdriver vs appium-windows-driver

FlaUI is a .NET library that links into the test process and calls UIA directly. By contrast:

  • winappdriver is a Microsoft-maintained HTTP/JSON service that exposes a W3C-WebDriver endpoint on 127.0.0.1:4723; tests speak Selenium-style protocol over the wire and the driver is language-agnostic.
  • appium-windows-driver is an Appium 2.x proxy that sits in front of WinAppDriver.exe and adds gestures / multi-window helpers.

Pick FlaUI when the test stack is already C# / .NET-first and you want in-process UIA calls without an HTTP hop. Pick winappdriver when you need a Selenium client in another language. Pick appium-windows-driver when you want the Appium feature surface on top of WinAppDriver.

When to use

  • Test code lives in a C# / .NET project alongside the application (a dotnet test solution).
  • Application under test is WPF, WinForms, Win32, or a Windows Store app - the four classes FlaUI documents support for (flaui (opens in new window)).
  • The team prefers strongly-typed control wrappers (AsButton(), AsTextBox()) over WebDriver's stringly-typed locators.
  • No HTTP wire protocol required between test and driver (in-process testing minimises a moving part).

For cross-language test stacks (Java / Python / Ruby clients), use winappdriver instead.

Authoring

NuGet packages

Per flaui (opens in new window), three packages cover the surface:

PackagePurpose
FlaUI.CoreBase library - element abstractions, Application, ConditionFactory, Retry, control patterns
FlaUI.UIA3COM-based UIA binding - recommended for WPF and Store Apps (flaui (opens in new window))
FlaUI.UIA2Managed UIA binding using System.Windows.Automation (msuia2 (opens in new window)) - better legacy WinForms compatibility (flaui (opens in new window))

Reference both FlaUI.Core and one of UIA2 / UIA3 from the test project. Mixed-mode authoring (UIA2 and UIA3 in the same process) is unsupported - see FlaUInspect (opens in new window) which requires the inspector mode to be picked at startup.

Launching the application under test

Per the FlaUI wiki - Application page (opens in new window):

using FlaUI.Core;
using FlaUI.UIA3;

// Launch a fresh process
var app = Application.Launch(@"C:\Path\To\MyApp.exe");

// Attach to an already-running process by name or PID
var existing = Application.Attach("MyApp");

// Best-effort: attach if running, launch otherwise
var aol = Application.AttachOrLaunch(new ProcessStartInfo(@"C:\Path\To\MyApp.exe"));

// For a Windows Store app, pass the AUMID
var store = Application.LaunchStoreApp("Microsoft.WindowsCalculator_8wekyb3d8bbwe!App");

using var automation = new UIA3Automation();
var window = app.GetMainWindow(automation);

Per flauiapp (opens in new window): "When the application object is disposed, the application itself is closed as well." Pair the Application lifecycle with the test harness's fixture scope so child processes are cleaned up after each test class.

Finding elements with ConditionFactory

The lambda form is the shortest and is the upstream convention (flauisearch (opens in new window)):

var loginButton = window.FindFirstDescendant(cf => cf.ByAutomationId("LoginButton"));

Prefer ByAutomationId (developer-set, locale- and theme-independent per msuia2 (opens in new window)); fall back to ByControlType + a nested condition, then ByName as a last resort. The equivalent ConditionFactory / PropertyCondition forms, the FindFirst* / FindAll* families, and the full condition-constructor list are in references/flaui-api.md.

Interacting with elements

Per flaui (opens in new window):

// Strongly-typed wrappers
var button = window.FindFirstDescendant(cf => cf.ByAutomationId("Submit")).AsButton();
button.Invoke();

var textbox = window.FindFirstDescendant(cf => cf.ByAutomationId("Username")).AsTextBox();
textbox.Enter("alice@example.com");

var listbox = window.FindFirstDescendant(cf => cf.ByControlType(ControlType.List)).AsListBox();
listbox.Select(2);

AsButton().Invoke() calls the UIA InvokePattern on the element - the accessibility-canonical "press" action, distinct from a synthetic mouse click (msuia2 (opens in new window) §Control Patterns).

Waits with the Retry class

Before v2.0.0 some Find methods auto-retried; that responsibility now falls to the caller (flauiretry (opens in new window)):

// Wait until the element appears
var found = Retry.WhileNull(
    () => window.FindFirstDescendant(cf => cf.ByAutomationId("StatusLabel")),
    timeout: TimeSpan.FromSeconds(10),
    interval: TimeSpan.FromMilliseconds(200),
    throwOnTimeout: true,
    ignoreException: true).Result;

// Wait until the element disappears
Retry.WhileTrue(
    () => window.FindFirstDescendant(cf => cf.ByAutomationId("Spinner")) is not null,
    timeout: TimeSpan.FromSeconds(30));

Retry.WhileNull / Retry.WhileTrue / Retry.WhileFalse / Retry.WhileException are the four variants (flauiretry (opens in new window)). Each returns a RetryResult carrying iteration count, duration, and the last value - the test can assert on those metrics when diagnosing slow-loading screens.

Waits with Application.WaitWhileBusy

WaitWhileBusy blocks while the target process is busy; a null timeout means infinite, and it returns true if the application went idle (flauiappsrc (opens in new window)):

public bool WaitWhileBusy(TimeSpan? waitTimeout = null)

Use it after a launch or a window-level action (menu open, modal dismiss, dialog confirm) before driving the next element - it blocks on the Win32 message-pump-idle signal of the target process. Pair with WaitWhileMainHandleIsMissing right after Launch so the test doesn't race the splash screen:

var app = Application.Launch(@"C:\Path\To\InvoiceApp.exe");
app.WaitWhileMainHandleIsMissing(TimeSpan.FromSeconds(10));
app.WaitWhileBusy(TimeSpan.FromSeconds(10));

var window = app.GetMainWindow(automation);
window.FindFirstDescendant(cf => cf.ByAutomationId("Save")).AsButton().Invoke();
app.WaitWhileBusy(TimeSpan.FromSeconds(5)); // wait for save handler

Retry.* waits on element-level conditions (descendant appears / disappears / matches a predicate); WaitWhileBusy waits on the process-level idle signal. Both belong in the same test - pick by what you can actually observe.

Running

Test framework integration

FlaUI integrates with any .NET test runner - xUnit, NUnit, MSTest:

// xUnit collection fixture for one-time app launch per test class
public class LoginAppFixture : IDisposable
{
    public Application App { get; }
    public UIA3Automation Automation { get; }
    public LoginAppFixture()
    {
        App = Application.Launch(@"C:\Path\To\LoginApp.exe");
        Automation = new UIA3Automation();
    }
    public void Dispose()
    {
        Automation.Dispose();
        App.Close();
        App.Dispose();
    }
}

public class LoginTests : IClassFixture<LoginAppFixture>
{
    private readonly LoginAppFixture _fx;
    public LoginTests(LoginAppFixture fx) => _fx = fx;

    [Fact]
    public void Logs_in_with_valid_credentials()
    {
        var window = _fx.App.GetMainWindow(_fx.Automation);
        window.FindFirstDescendant(cf => cf.ByAutomationId("User")).AsTextBox().Enter("alice");
        window.FindFirstDescendant(cf => cf.ByAutomationId("Pass")).AsTextBox().Enter("secret");
        window.FindFirstDescendant(cf => cf.ByAutomationId("Login")).AsButton().Invoke();
        Assert.NotNull(window.FindFirstDescendant(cf => cf.ByAutomationId("Welcome")));
    }
}

For per-test app launch (slower but isolates state), put Launch / Close in the test method itself; for per-class launch (faster but shared state), use IClassFixture (xUnit) / [OneTimeSetUp] (NUnit) / [ClassInitialize] (MSTest). Pair authoring conventions with xunit-tests, nunit-tests, or mstest-tests (in the qa-unit-tests-net plugin) for the matching harness idioms.

STA threading

UIA3 (COM interop) requires an STA thread (msuia2 (opens in new window)); xUnit defaults to MTA, so set the apartment via the runner attribute:

// xUnit - install Xunit.StaFact and use [StaFact]
[StaFact]
public void Fact_running_on_sta_thread() { /* ... */ }

// NUnit - use [Apartment]
[Test, Apartment(ApartmentState.STA)]
public void Test_running_on_sta_thread() { /* ... */ }

// MSTest - STA is default; no attribute needed for sync tests

UIA2 (managed) is more permissive, but keeping all UIA work on STA makes threading bugs easier to debug.

dotnet test invocation

:: Build + run
dotnet test --logger "trx;LogFileName=results.trx"

:: With a filter on the FlaUI smoke suite
dotnet test --filter "Category=Smoke" --logger "trx;LogFileName=smoke.trx"

Verify: run the suite and confirm it launches the app and passes. If a test fails with a NullReference or Retry timeout, the locator or wait is wrong - open FlaUInspect (opens in new window) to recheck the AutomationId, fix the FindFirstDescendant / Retry call, then re-run before adding more cases.

Parsing results

xUnit / NUnit / MSTest emit standard TRX / JUnit XML output via the test logger flag. Pair with junit-xml-analysis (in the qa-test-reporting plugin) for cross-runner aggregation.

For interactive selector discovery during authoring, use FlaUInspect (opens in new window) - per its README it is "based on FlaUI" and presents the UIA tree with AutomationId, Name, ControlType, and XPath fields. Pre-built FlaUInspect.UIA2 and FlaUInspect.UIA3 binaries are downloadable from the releases page; pick the build matching the UIA mode used by the test project.

CI integration

Windows runner required (UIA is Windows-only per msuia2 (opens in new window)); use windows-latest for an interactive desktop, since UIA cannot drive Session-0. Full windows-latest workflow: references/flaui-api.md.

UIA2 vs UIA3 selection

Per flaui (opens in new window):

ChooseWhen
UIA3WPF / Store Apps / new code - COM-based, fewer compatibility gaps with modern controls
UIA2Legacy WinForms / older Win32 - managed System.Windows.Automation (msuia2 (opens in new window)) handles some legacy controls UIA3 misses

For new projects, UIA3 is the default recommendation (flaui (opens in new window)). UIA2 remains supported as a peer binding; FlaUI itself ships both packages.

Anti-patterns

Anti-patternWhy it failsFix
Thread.Sleep(2000) between actionsTest runtime balloons; still flaky on slow CIUse Retry.WhileNull / Retry.WhileTrue with explicit timeout per flauiretry (opens in new window)
FindFirstByXPath("//Button[@Name='Save']")Brittle to UI tree restructuringUse ByAutomationId first; XPath only as last resort per flauisearch (opens in new window)
Finding solely by visible Name (ByName)Localised apps fail across languagesAutomationId is locale-independent per msuia2 (opens in new window)
Sharing one Application across all test classesUI state leaks between tests; one slow test halts the restUse one fixture per class (xUnit IClassFixture)
Forgetting app.Dispose() / automation.Dispose()Orphaned processes accumulate on CI runnerusing declaration or IDisposable fixture
Mouse-coordinate clicks (Mouse.Click(x, y))DPI / multi-monitor / theme changes breakResolve element via UIA, call Invoke()
Asserting on raw bitmap screenshotsBrittle to font / theme / DPIUIA tree is the assertion surface; screenshots only for canvas-rendered surfaces
Mixing UIA2 and UIA3 in one processUnsupported per FlaUInspect (opens in new window) inspector constraintPick one binding per test project

Limitations

  • Windows-only. UIA is a Windows-specific API per msuia2 (opens in new window). No macOS / Linux equivalent - see xctest-mac-desktop and at-spi-linux.
  • Requires an interactive desktop session. UIA cannot drive Session-0 / headless Windows containers. windows-latest GitHub runners are interactive by default; self-hosted containers need Auto-Login + an unlocked desktop.
  • UIA2 vs UIA3 picked once per process. Mixed-mode authoring is unsupported (flauinspect (opens in new window)). New code should prefer UIA3 (flaui (opens in new window)); UIA2 is retained for legacy WinForms compatibility but no hard deprecation date is published - pin the decision per project.
  • GPU / DirectComposition surfaces. Some WPF + WinUI 3 controls rendered via DirectX may not expose a UIA tree. Inspect with FlaUInspect (opens in new window); fall back to image matching for those surfaces.
  • App must publish UIA. Custom-painted Win32 windows that don't implement IRawElementProviderSimple are opaque to FlaUI (and to every other UIA-backed driver). Add UIA support in the application or fall back to image matching for those screens.

References

flaui-tests - locator forms and CI reference

View source (opens in new window)

flaui-tests - locator forms and CI reference

Alternate locator forms and the CI workflow, kept out of the SKILL spine. See SKILL.md (opens in new window) for the core launch, find, interact, and wait flow.

Sources: FlaUI Searching wiki (opens in new window), Microsoft Learn - UI Automation Overview (opens in new window).

Alternate locator forms

The lambda form (in SKILL.md) is the shortest and the upstream convention. Two equivalent forms resolve to the same UIA query:

// ConditionFactory form
var b = window.FindFirstDescendant(ConditionFactory.ByAutomationId("LoginButton"));

// Property + tree-scope form
var b3 = window.FindFirst(
    TreeScope.Descendants,
    new PropertyCondition(
        Automation.PropertyLibrary.Element.AutomationIdProperty, "LoginButton"));

Find method families (flauisearch (opens in new window))

  • FindFirstChild / FindAllChildren - immediate children only.
  • FindFirstDescendant / FindAllDescendants - full subtree.
  • FindFirstNested / FindAllNested - multi-level condition arrays.

Condition constructors: ByAutomationId, ByName, ByText, ByClassName, ByControlType, plus boolean combinators AndCondition / OrCondition / NotCondition.

Locator-selection order (most stable first)

  1. ByAutomationId - developer-set stable identifier per msuia2 (opens in new window); locale-independent and theme-independent.
  2. ByControlType + a nested condition - when no AutomationId is available, pair the control type (Button / Edit / ListItem) with another property.
  3. ByName - last resort; localised apps change Name per language.

CI integration

Windows runner required - UIA is Windows-only per msuia2 (opens in new window). windows-latest provides an interactive desktop session by default, required because UIA cannot drive Session-0 / non-interactive desktops. Self-hosted Windows-container runners need interactive logon + Auto-Login + an unlocked desktop.

# .github/workflows/flaui.yml
jobs:
  ui-tests:
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v5
      - uses: actions/setup-dotnet@v4
        with: { dotnet-version: '8.0.x' }
      - name: Build app under test
        run: dotnet build src/MyApp -c Release
      - name: Run FlaUI tests
        run: dotnet test tests/MyApp.UiTests --logger "trx;LogFileName=ui.trx"
      - uses: actions/upload-artifact@v4
        if: always()
        with:
          name: trx-results
          path: '**/ui.trx'

Related skills

appium-windows-driver

Authors and runs Appium 2.x tests against the Windows driver, the actively-maintained Node.js proxy in front of Microsoft's WinAppDriver: `appium driver install windows`, capabilities (`platformName: windows`, `appium:automationName: windows`, `appium:app`, `appium:appTopLevelWindow`, `appium:appArguments`), Windows gestures (`windows: scroll` / `clickAndDrag` / `keys`), PowerShell prerun/postrun hooks, and CI. Use when the stack already uses Appium for iOS / Android / Mac2 and Windows fits the existing client + capability model; to drive WinAppDriver directly from a Selenium-style client use winappdriver, and for a C#-only FlaUI client use flaui-tests.

at-spi-linux

Authors Linux desktop UI tests via AT-SPI - the DBus-based Assistive Technology Service Provider Interface implemented by `at-spi2-core` (registry daemon + `libatspi` C library + ATK GTK bridge). Covers enabling toolkit accessibility (`gsettings set org.gnome.desktop.interface toolkit-accessibility true`), driving GTK + Qt apps through Python `dogtail` (object-oriented + procedural APIs), inspecting the tree with Accerciser, scripting via `pyatspi`, and CI integration on headless Linux runners with `Xvfb` + `dbus-launch`. Use for Linux-side desktop tests of GTK applications, Qt apps with QAccessible enabled, and Electron apps on Linux.

desktop-test-strategy-reference

Pure-reference catalog of desktop GUI test strategies across Windows, macOS, and Linux. Defines the three accessibility-tree backends (Microsoft UI Automation on Windows, Apple Accessibility / XCTest on macOS, AT-SPI on Linux), the wrapper-tools that drive each backend (WinAppDriver, Appium-Windows, XCUIApplication, AT-SPI clients), the cross-toolkit Electron + Qt paths, and a per-OS decision matrix with accessibility-first locator strategy. Deep operational detail (per-OS asynchronous-wait hierarchies, parallel-test policy, foreground-lock / UAC / TCC / AT-SPI elevation hazards, and the high-DPI / per-monitor test matrix) lives in references/. Use when choosing how to test or automate a desktop GUI application (desktop app testing, GUI automation, automate desktop UI) on Windows, macOS, or Linux - the strategic reference before picking a desktop test stack, ahead of the per-tool implementation skills.

electron-playwright

Authors Playwright `_electron` tests for packaged Electron desktop apps - launches the app via `electron.launch({ args })`, returns an `ElectronApplication` handle, drives renderer windows as Playwright `Page` objects, and probes the main process via `electronApp.evaluate(({ app, BrowserWindow }) => …)`. Distinct from ordinary browser page automation: this wraps the `_electron` API for launching packaged Electron apps and probing main + renderer processes. Use for end-to-end tests of Electron apps where main-process state, IPC, and renderer DOM must all be asserted from one suite.

electron-spectron

Legacy reference for Spectron - Electron's original ChromeDriver-based testing framework, officially deprecated 2022-02-01 at v19.0.0. Documents what Spectron was, the architectural reason it became unmaintainable, the migration path to Playwright `_electron`, and the residual support contract for projects still on Spectron. Use only when auditing a legacy suite or planning a migration off Spectron - for new work use Playwright's `_electron` API.

qt-test-framework

Authors and runs Qt Test - the first-party C++ unit + GUI test framework that ships with Qt 6 (via the `QtTest` module header). Covers the `QTEST_MAIN` / `QTEST_APPLESS_MAIN` / `QTEST_GUILESS_MAIN` entry-point macros, the `QObject` private-slot test pattern, `QVERIFY` / `QCOMPARE` / `QFETCH` assertions, GUI event simulation (`QTest::mouseClick`, `QTest::keyClick`, `QTest::touchEvent`), `QSignalSpy` for signal introspection, `QBENCHMARK` for performance regression, and the `-o file,junitxml` CI output. Use for in-process testing of Qt widgets, QObject signal/slot chains, and Qt Quick / QML application logic; for out-of-process Qt-app driving, use an OS-native accessibility driver instead.

winappdriver

Authors and runs Windows UI tests against WinAppDriver, Microsoft's W3C-WebDriver service for UWP / WPF / WinForms / Win32 apps: installing + launching `WinAppDriver.exe` on `127.0.0.1:4723`, declaring `app` / `platformName` / `appArguments` / `appTopLevelWindow` capabilities, finding elements by `AccessibilityId` / `Name` / `ClassName`, and Windows-runner CI. Use when driving a native Windows app from a Selenium-style client (C#, Java, Python, Ruby, JS); for the actively-maintained Appium 2.x wrapper over the same server use appium-windows-driver, for a C#-only FlaUI client use flaui-tests, and to choose among Windows desktop drivers first use desktop-test-strategy-reference.

xctest-mac-desktop

Authors and runs XCTest UI + unit tests for macOS desktop apps - the Apple-first-party test framework that ships with Xcode. Covers the `XCTestCase` subclass + `test*` method-naming convention, `XCUIApplication` / `XCUIElement` / `XCUIElementQuery` for UI tests, accessibility-identifier-based locators (the stable replacement for label-based queries), `XCTAssert*` macros, `measureBlock:` for performance regressions, and `xcodebuild test` for CI execution. Use when the macOS app is built with Xcode and the test target is in-tree alongside the app - for cross-OS sharing see Appium Mac2 driver as a separate path.