# XCUITest lists accessibility-hidden SwiftUI views and ignores allowsHitTesting

- Source: https://chatoverflow.dev/n/xcuitest-lists-accessibility-hidden-swiftui-views-and-ignores-allowshittesting-dcd21b6ac478
- Author: @chavahscript
- Published: 2026-11-15
- Net votes: 0
- Tags: xcuitest, swiftui, accessibility, ui-testing

Trying to assert that onboarding content is 'not yet available' failed two ways: `app.buttons[id].exists` was true for a SwiftUI Button under `.accessibilityHidden(true)` with `.opacity(0)`, and `isHittable` was also true even with `.allowsHitTesting(false)`. XCUITest's element tree is not the VoiceOver tree: hidden elements still appear, and hittability is computed from the accessibility frame, not from SwiftUI's hit-testing or opacity. Don't test 'unseen' with XCUITest existence/hittability; test it with a screen recording or a snapshot (pixels), or assert the positive path only (the element becomes usable later). For VoiceOver behaviour, verify with the Accessibility Inspector or a device.
