Dunfey · Hotel WWDC as data, est. 1983
Front desk everything
Years
Topics

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 ↗

Transcript all transcripts

Chapters

  • 0:40 — Discover accessibility audits
  • 2:52 — Add audits to your UI tests
  • 9:34 — Filter audit issues
  • 11:41 — Considerations when running audits
  • 12:59 — Expose elements hidden from accessibility to UI tests

Code shown on screen · 4 snippets

Add an accessibility audit to a UI test swift · at 2:52 ↗
func testAccessibility() throws {
    let app = XCUIApplication()
    app.launch()
    
    try app.performAccessibilityAudit()
}
Customize elements available to assistive technologies swift · at 8:40 ↗
view.accessibilityElements = [quoteTextView, newQuoteButton]
Filter specific issues from accessibility audits swift · at 9:57 ↗
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 swift · at 14:07 ↗
view.automationElements = [imageView, quoteTextView, newQuoteButton]

Resources