Update Scan Name
Supported within:
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 an 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")
Note: Use this API to set the scan name before saving a result locally.
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)
}
}
}