Handle Results

Link to Handle Results copied to clipboard
Not for use with personal data

Running a scan returns an object containing info about accessibility issues in your app - such as the ID and description of the associated rule and that issue's impact. Review the results of your scan and reference our documentation to better understand accessibility rules. In the sample scan, you can see how to handle results within your tests, use them to generate reports, and send them to the Mobile Dashboard for your team to reference.

Using Results

What can you do with results? You can decide what is most useful for your team, but in the following example you can see a few of the possibilities. Get a count of the total number of accessibility failures, or discover the failure counts by severity level. Print a summary of failure counts by rule, and fail tests when critical issues are found.

let result = try axe.run(onElement: app)

// Get a count of the total number of accessibility failures.
let failureCount = result.failures.count

// Get a failure count by severity level (Minor, Moderate, Serious, Critical)
let criticalFailureCount = result.failures.filter { $0.impact == .CRITICAL }.count

// Fail the test if critical accessibility failures are found
XCTAssertEqual(criticalFailureCount, 0)

// Get the total number of failures for each rule
var totals: [String: Int] = [:]
for failure in result.failures {
    totals[failure.ruleId, default: 0] += 1
}

// Print a summary of failure counts by rule
for (rule, failureCount) in totals {
    print("\(rule) failures: \(failureCount)")
}
// ColorContrast failures: 12