Skip to main content

Native App Accessibility Automation

LambdaTest now enables native Accessibility Automation Testing for Android and iOS apps using Appium. This feature helps developers and QA teams to validate the accessibility of their mobile apps programmatically by leveraging LambdaTest's device cloud.

With built-in support for lambda-accessibility-scan, this integration ensures that your apps are tested for compliance with accessibility standards and best practices like WCAG (Web Content Accessibility Guidelines).

Prerequisites

Before getting started, ensure the following:

  • You have a LambdaTest account.
  • LambdaTest credentials (username & access key).
  • App uploaded to LambdaTest App Storage (lt://APP_ID).
  • Python 3 installed locally.
  • Appium-Python-Client installed
  • Access to a valid Android device on LambdaTest (real or virtual).

Native app accessibility automation supports both Android and iOS applications.

Step 1: Setup the Environment Variables

You need to export your environment variables LT_USERNAME and LT_ACCESS_KEY that are available in your LambdaTest Profile page. Run the below mentioned commands in your terminal to setup the environment variables.

export LT_USERNAME="undefined"
export LT_ACCESS_KEY="undefined"

Step 2: Upload your Application

Upload your iOS application (.ipa file) or android application (.apk or .aab file) to the LambdaTest servers using our REST API. You need to provide your Username and AccessKey in the format Username:AccessKey in the cURL command for authentication.

Make sure to add the path of the appFile in the cURL request. Below is an example cURL request to upload your app using our REST API:

curl -u "undefined:undefined" -X POST "https://manual-api.lambdatest.com/app/upload/realDevice" -F "appFile=@"/Users/macuser/Downloads/proverbial_android.apk"" -F "name="proverbial_app""
tip
  • If you do not have any .apk or .ipa file, you can run your sample tests on LambdaTest by using our sample apps, 🔗 Android app or 🔗 iOS app.

  • Response of above cURL will be a JSON object containing the APP_URL of the format - lt://APP123456789123456789 and will be used in the next step

Step 3: Configure required Capabilities

To enable accessibility testing, the following two configurations are mandatory:

  • Enable accessibility in capabilities:
"accessibility": True
  • Invoke scan via script:
driver.execute_script("lambda-accessibility-scan")

You may call lambda-accessibility-scan multiple times to scan different app screens or flows.

info

Sample Script

from curses import flash
import time
# import requests
from appium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import unittest
import os
from appium import webdriver
from appium.options.android import UiAutomator2Options
import sys
from selenium.webdriver.common.by import By
from appium.webdriver.client_config import AppiumClientConfig


options = UiAutomator2Options()
options.load_capabilities({
"platform": "android",
"platformVersion": "14",
"deviceName": "Galaxy S23 Ultra",
"isRealMobile": True,
"app" : "lt://YOUR_APP_ID",
"accessibility": True,
"buildName": "Accessibility-lambda",
"idleTimeout": 1800,
"build": "Accessibility Native App",
"name": "Android App Accessibility",
"devicelog": True,
"visual": True,
})
url = "https://YOUR_LT_USERNAME:YOUR_LT_ACCESS_KEY@mobile-hub.lambdatest.com/wd/hub"

client_config = AppiumClientConfig(
remote_server_addr=url,
ignore_certificates=True,
direct_connection=True
)

driver = webdriver.Remote(client_config.remote_server_addr, options = options, client_config=client_config)
driver.implicitly_wait(2)

time.sleep(10)
driver.execute_script("lambda-accessibility-scan")
time.sleep(10)
driver.find_element(By.CSS_SELECTOR, '#username').send_keys("Pbtest1") # Example CSS selector
driver.execute_script("lambda-accessibility-scan")

driver.quit()

For iOS accessibility automation, ensure you're targeting iOS 15 or later and include the "iosLiveInteraction": true capability in your configuration.

Step 4: Execute and Monitor your Tests

Run the following command in the directory where your project has been saved to execute your build.

python3 test.py

Accessibility Dashboard and Reporting

You can check the complete detailed report on the Accessibility Dashboard

automation-dashboard

Test across 3000+ combinations of browsers, real devices & OS.

Book Demo

Help and Support

Related Articles