Focus-Safe Windows UI Automation Test Harness (.NET)

    1

    Drive the real packaged EXE through UI Automation patterns only, with an isolated data directory, WS_EX_NOACTIVATE required, a WinEvent observer that fails the test on any foreground steal, state-based waits, evidence on hung close, and a private-desktop runner for tray tests

    $29

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIDeepSeekDeepSeekMuseMuse+22 more

    Focus-Safe Windows UI Automation Test Harness (.NET)

    Example session with this skill installed

    Our WPF app has a tray mode and runs on developers' machines all day. Write UI tests that drive the packaged EXE without ever stealing focus from the person using the PC, and prove it.

    • Read your context and instructions
    • Compiled the focus-safe windows ui

    Summary

    Harness referenced, four tests written, one app change required before the first run.

    What I did

    1. Built UiHarness (dotnet build src/UiHarness.csproj -c Release: 0 warnings, 0 errors) and referenced it from Acme.UiTests.
    2. Wrote a HarnessConfig for Acme Desktop: view map for Home, Settings, Activity log, Help; flags --data-dir, --local-only, --no-splash, --no-activate.
    3. Tests: GUI subsystem and quiet startup with an every-screen walk; settings toggle round trip; a second background launch that must not change the window; headless mode creating no windows.
    4. Ran them with APP_UNDER_TEST pointing at the packaged EXE.

    Result

    Launch failed on purpose: "The isolated app window must have WS_EX_NOACTIVATE when launched with the no-activate flag." Your --no-activate flag hides the splash but does not set the extended style, so the window could still take focus. Set WS_EX_NOACTIVATE in the main window's CreateParams when the flag is present and skip Activate().

    After that fix all four tests pass and focus-observation.json records foregroundEvents: 0 for each. The tray test is marked for the private desktop: run it with pwsh scripts/Run-OnPrivateDesktop.ps1 -ExePath <exe> -Command 'dotnet test Acme.UiTests --filter Category=Tray'; the worker writes private-desktop-evidence.json with switchedDesktop: false.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    UI suites that click coordinates break on layout changes; suites that send input steal the keyboard from whoever is at the machine; suites that pass on a debug build miss what the packaged app does. This harness drives the real executable through UI Automation patterns only, keeps its window from ever activating, proves it, and moves the few tests that need activation onto a private desktop nobody sees.

    AppDriver (C#, .NET 8 Windows, no packages): launches APP_UNDER_TEST with a fresh data directory under %TEMP% and your local-only, no-splash and no-activate flags; waits for the main window; requires WS_EX_NOACTIVATE; finds by AutomationId or Name; acts through Invoke, SelectionItem, Toggle, Value and ExpandCollapse patterns (never SendInput, mouse or keyboard); Nav waits for the view-name element so a SetText cannot land on a control the next screen replaces; WaitIdle judges off-screen visibility by bounding rectangle; Close returns the exit code or writes window states to close-failure.json and kills the tree after 60 seconds; VisibleWindows(pid) for headless modes.

    ForegroundWatch: out-of-process WinEvent hook on EVENT_SYSTEM_FOREGROUND filtered to the app's process; writes focus-observation.json on dispose and throws if the app ever took focus, with private-desktop activations recorded separately.

    PrivateDesktop + Run-OnPrivateDesktop.ps1: CreateDesktop in the interactive window station, CreateProcess with lpDesktop for the worker, no SwitchDesktop or input APIs anywhere; the worker refuses to run on the input desktop and writes private-desktop-evidence.json.

    Reference: the design principles, what the app must expose, and the evidence files. Example xunit tests included: GUI subsystem check, quiet startup and every-screen walk, settings round trip, quiet second launch, headless mode, tray minimize/close/restore. Builds with dotnet build; no network.

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Testing & Debugging.

    Windows only. Requires interactive session. Cannot see custom controls lacking Automation Peers. Example tests require adaptation to your specific app IDs and flags.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 18 days ago

    Software
    dotnet pwsh windows

    Permissions

    Write Files
    Terminal / Shell
    Read Files
    Environment Variables

    Starts the executable you name with an isolated data directory under %TEMP%, drives it through UI Automation, and writes evidence JSON files there. The private-desktop runner creates a Windows desktop object and a worker process. No network; reads APP_UNDER_TEST and UI_HARNESS_PRIVATE_DESKTOP only.

    Listed18 days ago

    What's inside

    Frequently Asked Questions

    Traditional UI testing 'steals' the mouse and keyboard, preventing you from working during a test run. This harness uses UI Automation patterns and private desktops to interact with apps invisibly, allowing you to code or browse while tests run in the background.

    The package includes the full .NET 8 source code for the harness, a pre-configured C# library, and PowerShell scripts for managing private desktop isolation. You also receive documentation for integrating it into existing xUnit or nUnit test suites.

    No, this is a Windows-only tool. It requires an interactive window station to render the UI, meaning it works on local machines or specialized CI runners but will not work on headless Linux environments or standard service-hosted agents.

    The harness works with any .NET-compatible AI agent or developer tool. As long as your agent can execute C# commands or trigger PowerShell scripts, it can utilize this harness to perform autonomous UI testing and verification.

    The harness targets the UI Automation (UIA) tree. It works perfectly with standard WPF, WinForms, and WinUI controls; however, custom-drawn elements (like those in some game engines) that do not implement UIA peers will not be visible.

    New in Testing & Debugging