Perfecto with Espresso Example

Link to Perfecto with Espresso Example copied to clipboard

Test your Android app for accessibility issues on devices from Perfecto.

Not for use with personal data

Run your UI Tests on Perfecto to get a comprehensive understanding of your app's accessibility health across devices.

Requires:

  • Perfecto Enterprise Private Cloud

Prerequisites

Your UI Tests are integrated with axe DevTools Mobile for Android. Check out our getting started guide if needed.

Example Project

Looking for an example? Our Sample Android Project has an integration ready to test.

  1. Verify that you have the prerequisites.
  2. Download the sample project from Github.
  3. Add your axe DevTools for Mobile API key to app/build.gradle.
  4. Adjust the values for cloudURL and securityToken in configFile.json to match your Perfecto cloud:
{
  "cloudURL": "<<perfecto-cloud-name>>",
  "securityToken": "<<security-token>>",
  ...
}
  1. Add your security token as an environment variable (SECURITY_TOKEN) (or attach to end of the next command).
  2. In the terminal, run a test on Perfecto: ./gradlew perfecto-android-inst -PconfigFileLocation=configFile.json -PcloudURL=demo.perfectomobile.com -PsecurityToken=$SECURITY_TOKEN

There are three files in the sample project used for Perfecto integration: app/build.gradle, configFile.json, and build.gradle.

Add Perfecto to Your Espresso Test

Setup

  1. In your project's build.gradle file, add:

repositories {
  ...
  maven { url "https://repo1.perfectomobile.com/public/repositories/maven" }
  ...
}

dependencies {
  ...
  classpath 'com.perfectomobile.instrumentedtest.gradleplugin:plugin:+'
  ...
}
  1. In app/build.gradle, add:
plugins {
  ...
  id 'com.perfectomobile.instrumentedtest.gradleplugin'
  ...
}
  1. Add Perfecto's configuration JSON and review the following values to match your Perfecto authentication and application:
    • cloudURL
    • securityToken
    • apkPath
    • testApkPath
{
  "cloudURL": "<<cloud name>>",
  "securityToken": "<<security-token>>",
  "numOfDevices": 2,
  "jobName": "Espresso_Axe_Sample",
  "jobNumber": 1,
  "branch": "some_branch",
  "projectName": "My_Espresso_project",
  "projectVersion": "v1.0",
  "tags": [
    "espresso",
    "plugin"
  ],
  "apkPath": "app/build/outputs/apk/debug/app-debug.apk",
  "testApkPath": "app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk",
  "installationDetails": {
    "preCleanUp": "true"
  },
  "postExecution": {
    "uninstall": "false"
  },
  "debug": false,
  "failBuildOnFailure": true,
  "takeScreenshotOnTestFailure": true,
  "shard": true,
  "testTimeout": 60000
}

Run

Once your project is set up, run a test on Perfecto from the terminal:

./gradlew perfecto-android-inst -PconfigFileLocation=configFile.json -PcloudURL=demo.perfectomobile.com -PsecurityToken=$SECURITY_TOKEN
note

The cloudURL value should reflect your Perfecto cloud URL, and securityToken should reflect your Perfecto security token.