Run XCUI accessibility tests

What is XCUI Accessibility Audit?

The Accessibility Audit is a new feature in the XC User Interface Tests that provides ability to perform accessibility checks directly from your existing tests. The checks can be applied to different kinds of elements and views. Also, it’s possible to configure the list of used checks to focus on particular accessibility areas and override the default behavior for failed validations.
More information can be found here and in the following video.

Prerequisite: Add and configure Accessibility Audit in existing tests

The Accessibility Audit is introduced in Xcode 15 and is automatically available for use in any XCUI Test.

    func testMyAccountView() throws{
        app.tabBars["bottomTabBar"].buttons["My account"].tap()
        // exclue some accessibility checks
        var baseOrderViewChecks = XCUIAccessibilityAuditType.all
        // performAccessibilityAudit action is part of XCUIApplication class
        try app.performAccessibilityAudit(for: baseOrderViewChecks)

Also, here is an example of configuring behavior for specific failed checks :

    func testProductsView() throws{
        var baseProductsViewChecks = XCUIAccessibilityAuditType.all
        try app.performAccessibilityAudit(for: baseProductsViewChecks) {issue in
            //skip hit area verification for Price icon
            var ignore = false
            if let element = issue.element,
               issue.auditType == .hitRegion {
                ignore = true
            return ignore

A full example of using the Accessibility Audit can be found in our Demo project.

Build and execute tests

The way of building and executing Accessibility Audit tests is the same as for regular XCUI tests and all details can be found here.
Important: please use only iOS 17+ devices for execution, because the Accessibility Audit feature is not available for the below versions.

Find results in execution log

As a result of the XCUI test execution, we provide a detailed log, where you can also find accessibility checks info.

Here is an example of such information:

.../Repos/demo-ios-app/MobitruUITests/Accessibility/ViewAccessibilityTests.swift:21: error: -[MobitruUITests.ViewAccessibilityTests testLoginView] : Contrast failed
tTime:Test Case '-[MobitruUITests.ViewAccessibilityTests testLoginView]' failed (10.788 seconds).

.../Repos/demo-ios-app/MobitruUITests/Accessibility/ViewAccessibilityTests.swift:65: error: -[MobitruUITests.ViewAccessibilityTests testMyAccountView] : Label not human-readable
    t =    12.93s Tear Down
tTime:Test Case '-[MobitruUITests.ViewAccessibilityTests testMyAccountView]' failed (13.143 seconds).
Scroll to Top