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

Dopo aver importato e inizializzato il framework axeDevToolsXCUI, sei pronto per la scansione. Esegui una scansione in qualsiasi punto dei test dell'interfaccia utente, passando qualsiasi elemento XCUIElement su cui desideri testare l'accessibilità. Nell'esempio seguente, stiamo passando XCUIApplication per testare tutte le viste attualmente presenti nel flusso dell'app.

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

Scansione di esempio

import axeDevToolsXCUI
import XCTest

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

    override func setUpWithError() throws {
        axe = try AxeDevTools.login(withAPIKey: "<DEQUE_APIKEY>")

        app.launch()
    }

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

        // Send results to the dashboard in case of a failure.
        if result.failures.count > 0 {
            try axe?.postResult(result)
        }

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

Deinitialize

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

override func tearDown() {
    axe = nil
  }

Qual è il prossimo passo?

Scopri di più su come caricare i risultati della scansione sulla dashboard mobile e salvare i risultati localmente.