UIAutomator

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

以下に、UIAutomatorを使用したAxe DevToolsテストの開始に関する完全な例を示します。Axe DevTools Mobileでアクセシビリティテストをカスタマイズするための詳細は、必ずAndroid SDKの機能セクションを確認してください。

class ExampleInstrumentedTestWithAccessibility : Utils {
    
    val axe = AxeDevtools()

    @Before
    fun setup() {
        ...
        // Authenticate and initiate your axe object for testing.
        axe.loginWithApiKey("api_key")
        axe.setInstrumenation(InstrumentationRegistry.getInstrumentation())
        ...
    }

    @Test
    fun allyScan() {
        ...
        // At any point within your automated tests, initiate a scan. 
        // You may check the results locally, or push to Axe Developer Hub for further collaboration and analysis.
        
        val scanResultHandler = axe.scan()

        //Option 1. Upload it to Axe Developer Hub
        scanResultHandler?.uploadToDashboard()

        //Option 2. Using the results in your test suite
        val result: AxeResult? = scanResultHandler?.getSerializedResult()
        result?.axeRuleResults?.forEach { result ->
            if(result.status == AxeStatus.FAIL) {

            }
        }

        //Option 3. Save the result JSON to a local file for later use
        scanResultHandler?.saveResultToLocalStorage("your_file_prefix")
            ...
        }
}