A sample application built solely to showcase axe DevTools Android automated espresso test implementation. It is non-functional and made inaccessible by design.
- Library documentation and more information on automated or manual testing can be found at docs.deque.com.
- Learn more about Deque and axe DevTools Mobile here.
We currently support two ways to scan your app for accessibility issues, both delivered through our Gradle Plugin.
Users looking to keep the amount of code needed to implement our library to a minimum should look at
Auto Scan. Enabling it lets our Gradle Plugin take on the boilerplate for you. With a few lines of
configuration in your build.gradle file, a report is generated for you that covers the accessibility
violations in your app, with no test code required. We prefer this implementation in our own use of this library, so please try it out!
For those who would like more control over when and what gets scanned, you can run targeted scans by
calling axe.scan() directly in your tests. This lets you scan a specific screen or state exactly when
you want to.
- Clone the repository.
- Set up a new project on axe Developer Hub to set up a Project ID and API Key.
- In
app/build.gradle, addid 'com.deque.android' version '1.+'to your plugins block, then add your API key and project ID to the axeDevTools block and setaxeAutoScanMode = trueas shown in the example below.
axeDevTools {
axeMobileApiKey = axe_apikey
axeProjectId = axe_project_id
axeAutoScanMode = true
}If you would like to customize the implementation of this further the following example shows all the configuration options we have available to you:
axeDevTools {
axeMobileApiKey = axe_apikey
axeProjectId = axe_project_id
axeAutoScanMode = true // to enable auto scan mode (default false)
axeUploadResults = false // if you want to only look at results locally (default true)
axeAccountUrl = "https://www.custom-url.com" // found in your project settings on axe Developer Hub (default https://axe.deque.com)
axeHtmlReportPath = "/path/to/desired/folder" // customize where your accessibility reports are saved (defaults to your project's build/reports directory)
}Targeted scans use the same Gradle Plugin, but with Auto Scan turned off so you control when scans run. Call axe.scan() in your tests wherever you want to capture results — see InstrumentationRegistryExampleTest and AxeTestClass for a working example.
-
Clone the repository.
-
Set up a new project on axe Developer Hub to set up a Project ID and API Key.
-
In
app/build.gradle, addid 'com.deque.android' version '1.+'to your plugins block and add your API key and project ID to the axeDevTools block (leaveaxeAutoScanModeomitted or set tofalse):axeDevTools { axeMobileApiKey = axe_apikey axeProjectId = axe_project_id } -
Call
axe.scan()in your test code where you want to run a scan, as shown inAxeTestClass.
Prefer to manage the dependency yourself? Instead of applying the Gradle Plugin, you can add our base library directly with
androidTestImplementation 'com.deque.android:axe-devtools-android:current-release'in yourdependenciesblock. Note that Auto Scan is not available when using this approach.
Once you have set up either Auto Scan or a Targeted Scan, you are ready to start scanning the application using the Espresso tests.
You can see accessibility testing in action through the AutoScanDemoTest and InstrumentationRegistryExampleTest tests, or any other test in the androidTest folder.
These include examples using Jetpack Compose and UiAutomator.
You can kick it off from Android Studio, or through an automated service such as Perfecto, Sauce Labs, etc.
Note:
- This project is set to use the Android Gradle plugin version 8.10.1. Running the project with newer, or older, JDK versions may require you to update the Gradle plugin version accordingly. Please refer to Android's Updating the Gradle Plugin documentation for more.
If you have an account with Perfecto, you can run the automated tests of this application by using our prewritten Perfecto configuration file configFile.json that shards the tests across any two available devices. Follow the steps below to get started:
-
Project's build.gradle: Add to repositories section. Add
classpath 'com.perfectomobile.instrumentedtest.gradleplugin:plugin:+'to dependencies section. See Configure the project for Perfecto section -
app/build.gradle: Add
id 'com.perfectomobile.instrumentedtest.gradleplugin'to plugins section. -
Update the prewritten
configFile.jsonif needed. See Android configuration parameters -
Run a test on Perfecto from the terminal:
./gradlew perfecto-android-inst -PconfigFileLocation=configFile.json -PcloudURL=demo.perfectomobile.com -PsecurityToken=$SECURITY_TOKENwhere cloudURL should reflect your Perfecto cloud URL and securityToken should reflect your Perfecto's security token.
Reach out to Perfecto Support for any assistance.
If you have an account with Sauce Labs, you can run the automated tests of this application by using our prewritten Sauce Labs configuration file .sauce/config.yml. Follow the steps below to get started:
-
Install the
saucectlcommand line interface. See Using the saucectl CLI -
Add your Sauce Labs credentials to your
.bash_profileor.zshenv. Be sure to load the changes by runningsource .filename. See Associate your Credentials -
Update the prewritten
.sauce/config.ymlSee Configuring Your Espresso Tests -
Run a test on Sauce Labs from the terminal:
./gradlew app:assembleDebug && ./gradlew app:assembleAndroidTest && ./saucectl run
Reach out to us, we'd love to help!