2023 Developer ToolsAccessibility & Inclusion
WWDC23 · 16 min · Developer Tools / Accessibility & Inclusion
Perform accessibility audits for your app
Discover how you can test your app for accessibility with every build. Learn how to perform automated audits for accessibility using XCTest and find out how to interpret the results. We’ll also share enhancements to the accessibility API that can help you improve UI test coverage.
Watch at developer.apple.com ↗Chapters
Code shown on screen · 4 snippets
Add an accessibility audit to a UI test
func testAccessibility() throws {
let app = XCUIApplication()
app.launch()
try app.performAccessibilityAudit()
} Customize elements available to assistive technologies
view.accessibilityElements = [quoteTextView, newQuoteButton] Filter specific issues from accessibility audits
try app.performAccessibilityAudit(for: [.dynamicType, .contrast]) { issue in
var shouldIgnore = false
// ignore contrast issue on "My Label"
if let element = issue.element,
element.label == "My Label",
issue.auditType == .contrast {
shouldIgnore = true
}
return shouldIgnore
} Customize automation elements available to UI tests
view.automationElements = [imageView, quoteTextView, newQuoteButton] Resources
Related sessions
-
41 min