Save Results Locally
When you save scan results locally, you can use the JSON result to integrate accessibility metrics into different reporting tools. You can also create an HTML report to share via email or chat, to notify your team of the accessibility health of your test run.
Saving results locally is only supported within automated testing.
Save and Share Results
Use the following code to save test results as a .json file. If the path and file name are not specified, the results will be named "(APPID)-(CURRENT_SCREEN_TITLE).json" and will be saved in a folder called "AxeDevToolsResults" within your User folder. The scan name will default to the title of the view controller if available.
try axe?.saveResult(result, toPath: "", withFileName: "", withScanName: "")Generate an HTML Report and Summary
Add a call to generateHtmlReportAndSummary in your test tear-down to produce a self-contained HTML report and save it locally to your device. This API call flushes any stored result files and gathers all scans accumulated since the session started (or since the last call to the method). Calling generateHtmlReportAndSummary multiple times within a run produces separate reports per flow (e.g. one per screen or feature area).
When your test suite finishes, a self-contained HTML report is written to a specified directory. Look at the path logged to the console to locate the report file. You can write reports to a specific directory with the outputPath parameter, providing an absolute path or a ~-prefixed path. The path defaults to ~/AxeDevToolsMobileResults when omitted, or nil.
@discardableResult
public func generateHtmlReportAndSummary(outputPath: String? = nil) throws -> AxeReportResultThese reports will include screenshots and rule failures only. For more detailed reporting that will include the view hierarchy, rules that were marked as passed or incomplete, and details about rule failures, you should use the Axe DevTools Reporter CLI.
Use Results for Detailed Reporting
Utilize the Axe DevTools Reporter CLI to build an HTML report from a set of scans. Alternatively, you can access the result files programmatically to integrate accessibility metrics with internal reporting tools.
Full Example
func testAccessibility() throws {
guard let result = try axe?.run(onElement: XCUIApplication()) else { XCTFail(); return }
//Save Result Locally
let path = try axe?.saveResult(result)
print("Result saved to location: \(path)")
//Any assertions
XCTAssertEqual(result?.failures.count, 0)
}Support on Cloud Testing Platforms
Saving a result locally will not work as expected on Cloud Testing Platforms. If you need support for Cloud Testing Platforms, please send a request to helpdesk@deque.com or at support.deque.com.
