Delete a Scan

Link to Delete a Scan copied to clipboard

Supported within:
axeDevTools UIKit framework axeDevTools XCUI framework

Scans can accumulate pretty quickly while testing for accessibility. After sending a scan to the axe DevTools Mobile Dashboard and determining it's no longer needed, use the below API to remove the scan from the dashboard. The ability to remove results no longer necessary helps highlight the scans in the dashboard that require attention.

Deleting a scan is only supported within automated testing.

Delete a Scan from the Result Key

When pushing a scan to the dashboard, you'll get an AxeDevToolsResultKey object returned. On the initialized AxeDevTools object, use the key to remove the scan from the dashboard.

try axeDevTools?.deleteResult(resultKey)

axeDevToolsUIKit Example

Unit Tests UI Tests

Unit Test Example

In this snippet, we'll remove the scan from the dashboard if zero failures were found.

func testAccessibility() throws {
    let view = HomeViewController()

    guard let result = try axe?.run(onViewController: view), 
          let resultKey = try axe?.postResult(result) else
    {
        XCTFail()
        return
    }
    
    if result.failures.count == 0 {
        try axe?.deleteResult(resultKey)
    }
}

UI Test Example

In this snippet, we'll remove the scan from the dashboard if zero failures were found.

func testAccessibility() throws {
    let FAB_ID = "com.deque.axeDevTools.accessibilityFab"
    let fab = app.buttons[FAB_ID]

    // Tap the FAB to send the scan to the server
    fab.tap()

    // Once it returns, the result from the scan can be seen on the Dashboard.
    // The FAB's label has the key needed to retrieve the scan from the server.
    XCTAssert(fab.waitForExistence(timeout: 5))

    // Grab the result from the server
    guard let key = AxeDevToolsResultKey(fabTitle: fab.label) else {
        XCTFail("Could not retrieve scan from the server.")
            return
    }

    let result = try axe?.getResult(key)
    
    if result.failures.count == 0 {
        try axe?.deleteResult(resultKey)
    }
}

axeDevToolsXCUI Example

UI Tests

In this snippet, we'll remove the scan from the dashboard if zero failures were found.

func testAccessibility() throws {
    guard let result = try axe?.run(onElement: app), let resultKey = try axe?.postResult(result) else
    {
        XCTFail("Result Unavailable")
        return
    }
        
    if result.failures.count == 0 {
        try axe?.deleteResult(resultKey)
    } 
}