Setup for Automated Testing

This page is not available in the language you requested. You have been redirected to the English version of the page.
Link to this page copied to clipboard

Add the framework into your UI tests

Not for use with personal data

Automated Testing

XCTest is required to run axeDevToolsXCUI. Other UI testing frameworks are supported that utilize XCTest.

Setup for Testing

In any file used for accessibility testing, import the axeDevToolsXCUI framework.

import axeDevToolsXCUI

Create an object within your testing class to hold onto the axe DevTools instance:

var axe: AxeDevTools?

Initialize the framework within the setUp or setUpWithError methods.

Start a Testing Session

Generate an API key at axe.deque.com. To post results to axe Developer Hub, use startSession with the API Key and Project ID from Developer Hub.

axe = try? AxeDevTools.startSession(apiKey: "<DEQUE_APIKEY>",
            projectId: "<DEVHUB_PROJECT_ID>")

If you only want to save results locally, you do not need to include the Project ID.

axe = try? AxeDevTools.startSession(apiKey: "<DEQUE_APIKEY>")

Setup Example

import axeDevToolsXCUI
import XCTest

class MyUITests: XCTestCase {
    var axe: AxeDevTools?
    var app = XCUIApplication()

    override func setUpWithError() throws {
        axe = try AxeDevTools.startSession(apiKey: "<DEQUE_APIKEY>",
            projectId: "<DEVHUB_PROJECT_ID>")
        // Include the projectId to post results to axe Developer Hub (recommended)
        app.launch()
    }
}

What's Next?

Now that you have created a project and integrated the axeDevToolsXCUI framework, you are all set to scan your mobile app. Optionally, you can customize your configuration before you scan, if you want to name your scans, ignore certain results, create custom rules, or tag scans.