-
Notifications
You must be signed in to change notification settings - Fork 8
GUI Validation Methods
Comparison of two approaches for validating the Avalonia GUI: MCP Computer Use (visual screenshot-based) vs PowerShell UI Automation (structural element tree).
- Target view: Unit Editor — Eirika (Unit 01) in FE8U
- App: FEBuilderGBA Avalonia (Debug build, .NET 9.0)
- Screen: 3240x2160 (Windows 11, 200% DPI scaling)
- Date: 2026-03-23
The MCP Computer Use server (tools/mcp-computer-use/) provides screenshot capture, mouse click, keyboard input, and window management via JSON-RPC over stdio.
| Aspect | Result |
|---|---|
| Editor opened correctly | "Unit Editor" title visible with address 0x00803D64
|
| Correct unit selected | Eirika portrait rendered (teal-haired character sprite) |
| Identity fields | Name ID=530, Name="Eirika", Unit ID=1, Class="02 Lord", Portrait=2 |
| Base stats | LV=1, Lck=5, all other stats visible and readable |
| Weapon levels | Sword=1 (rank E), all weapon types displayed |
| Visual layout | Sections (Identity, Base Stats, Weapon Levels) properly separated |
| Portrait rendering | Sprite image renders correctly with proper colors |
| Navigation | Unit list on left with portrait thumbnails, scrollable |
Screenshots are captured at full screen resolution (3240x2160) and scaled to max 1200x800.
- Scale factor: 2.7x
- Click coordinates: screenshot pixel position x 2.7 = screen coordinates
-
Tip: Always
focus_windowbefore clicking — the terminal steals focus
- Zero setup beyond existing MCP server
- Validates what the user actually sees
- Catches visual bugs (wrong colors, misaligned layout, missing images)
- Works for all 356 Avalonia views without any code changes
- Pixel-level comparison can be flaky with font rendering differences
- Cannot assert exact numeric values without OCR (rely on visual inspection)
- Slower than structural queries (screenshot + network round-trip)
Uses System.Windows.Automation (UIAutomationClient) to inspect the Avalonia window's automation element tree.
=== WINDOW FOUND ===
Name: FEBuilderGBA - FE8U.gba
ClassName: MainWindow
BoundingRect: 405,450,3236,2119
=== TOTAL DESCENDANTS: 279 ===
=== ELEMENTS WITH AUTOMATION IDs: 40 ===
| Element Type | Count | What's visible |
|---|---|---|
| Text elements | 34 | Status bar, expander headers only |
| Edit fields | 1 | Filter textbox only |
| Combo boxes | 0 | None |
| List items | 0 | None |
| Buttons with AutomationId | 34 | Expander headers (Characters, Items, Maps...) |
The entire Unit Editor content is invisible to UI Automation:
- No edit fields (Name ID, Unit ID, stats — all missing)
- No combo boxes (Class ID, Affinity dropdowns — missing)
- No list items (unit list with portraits — missing)
- No images (portrait rendering — impossible)
-
Avalonia's
AutomationPeersupport is opt-in — controls without explicit automation peers are invisible -
Editor views don't set
AutomationProperties.AutomationIdon their controls -
Dynamically-loaded user controls inside
ContentControlareas aren't exposed to the automation tree - Only the main window shell (menu, status bar, expander headers) has automation support
- Deterministic — no visual comparison needed
- Can read exact text values programmatically
- Scriptable for CI/CD pipelines (headless capable)
- Fast queries once the tree is built
- Blind to all editor content in current state
- Requires adding
AutomationProperties.AutomationIdto hundreds of controls across 356 views - Avalonia's UI Automation is less mature than WinForms
| Validation Target | MCP Computer Use | PowerShell UI Automation |
|---|---|---|
| Unit Editor opened | Screenshot shows title + address | Cannot detect |
| Eirika selected | Portrait visible, name readable | Cannot detect (0 list items) |
| Name ID = 530 | Visible in screenshot | Cannot detect (0 edit fields) |
| Class = 02 Lord | Visible in combo box | Cannot detect (0 combo boxes) |
| Base Stats (LV 1, Lck 5) | Visible in stat fields | Cannot detect |
| Portrait renders correctly | Teal-haired sprite visible | Impossible (no visual) |
| Layout/spacing correct | Sections properly separated | Impossible |
| Status bar text | N/A | `FE8U.gba |
| Menu structure | Visible in screenshot | 34 expander headers enumerable |
Use MCP Computer Use as the primary GUI validation method for this project.
- Most validations are visual (portrait rendering, map display, color accuracy)
- Works out of the box with zero code changes to Avalonia views
- Validates the actual user experience, not just the element tree
- Already configured in
.mcp.jsonand ready to use
Use PowerShell UI Automation only for:
- Status bar assertions (ROM version, file size)
- Main menu structure verification (expander presence)
- Future: if
AutomationProperties.AutomationIdis added to editor controls
Future path for CI-driven UI tests:
- Add
AutomationProperties.AutomationIdincrementally to editor .axaml views - Or use Avalonia's built-in headless test framework for programmatic UI testing without a display
Generated with Claude Code — Claude Opus 4.6 (1M context)