Update Scan Name

Link to Update Scan Name copied to clipboard

Supported within:
XML Compose

Scans uploaded to the dashboard automatically grab the view's title if available. You can set the name based on other criteria before pushing a scan.

Option 1: Setup When Initialized

To name a scan during manual testing, or to have a name that will remain the same for the current test run (think app or screen name), you can set the scan's name when initializing the AxeDevTools or AxeDevToolsCompose object.

val axe = AxeDevTools() //or AxeDevToolsCompose()
axe.setScanName("Scan Name")

Option 2: Tag After Scanning

The other option supported in automated testing is to call the setScanName function from the DashboardService object after uploading to the dashboard.

XML Example

protected fun nameYourScanForXml() {
    rule.scenario.onActivity {
        val axeResult = axe.scan(it)?.uploadToDashboard()
        runBlocking {
            nameScan(axeResult, "Scan Name")
        }
    }
}

private suspend fun nameScan(
    axeResult: AxeDevToolsResult?, 
    scanName: String
) {
    withContext(Dispatchers.IO) {
        axeResult?.axeDevToolsResultKey?.let { key -> 
            DashboardService.setScanName(key, scanName)
        }
    }
}

Compose Example

protected fun nameYourScanForCompose() {
    val axeResult = axeCompose.scan()?.uploadToDashboard()
    runBlocking {
        nameScan(axeResult, "Scan Name")
    }
}

private suspend fun nameScan(
    axeResult: AxeDevToolsResult?, 
    scanName: String
) {
    withContext(Dispatchers.IO) {
        axeResult?.axeDevToolsResultKey?.let { key -> 
            DashboardService.setScanName(key, scanName)
        }
    }
}