2

I've been tweaking the accessibility of a feature of our app after an Accessibility audit. The result, when using the app with VoiceOver, for example, is conform to the requests of the audit.

For example, in a view, I applied accessibility traits to container views (HStack, for example). Those same container views have accessibility IDs set to them.

HStack { // content view representing a header } .accessibilityIdentifier("headerAccessibilityID") .accessibilityAddTraits([.isButton, .isHeader]) 

I want to create a test that validate, for example, that the view with Accessibility ID "feature_header" has traits [.isHeader, .isButton].

 let elem = application.descendants(matching: .any)["headerAccessibilityID"] XCTAssert(elem.accessibilityTraits.contains(UIAccessibilityTraits.header)) 

In the test, I can successfully query my element, but when I inspect its traits, it always returns UIAccessibilityTraits(rawValue: 0), aka .none (see doc). Is this even possible to do? If so, how? Does the lack of introspection in SwiftUI makes it impossible to test?

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.