Esegui una scansione

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
Not for use with personal data

Pronti, partenza, scansione

Una volta importato e inizializzato il framework axeDevToolsXCUI, sei pronto per eseguire una scansione. Esegui una scansione ovunque nei tuoi test UI passando qualsiasi XCUIElement con cui desideri verificare l'accessibilità. Nell'esempio seguente, stiamo passando il XCUIApplication per testare tutte le viste attualmente visualizzate nel flusso dell'applicazione.

func testAccessibility() throws {
    let result = try axe?.run(onElement: app)
}

Esempio di Scansione

import axeDevToolsXCUI
import XCTest

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

    override func setUpWithError() throws {
        axe = try AxeDevTools.startScanSession(apiKey: "<DEQUE_APIKEY>",
            projectId: "<DEVHUB_PROJECT_ID>")

        app.launch()
    }

    func testAccessibility() throws {
        guard let result = try axe?.run(onElement: app) else {
            XCTFail()
            return
        }

        // Send results to axe Developer Hub.
        try axe?.postResult(result)

        // Fail the build if failures were found
        XCTAssertEqual(result.failures.count, 0)
    }
}

Deinizializzare

Come buona prassi, deinzializza l'oggetto axe utilizzando una funzione tearDown per cancellare lo stato dei test precedenti.

override func tearDown() {
    axe = nil
  }

E adesso?

Scopri di più su caricare i risultati della scansione su Axe Developer Hub e salvare i risultati localmente.