|
| 1 | +--- |
| 2 | +id: accessibility-android-test |
| 3 | +title: Automation Tests with Accessibility Tool using Android |
| 4 | +sidebar_label: Android |
| 5 | +description: Use LambdaTest Accessibility DevTools to detect and report accessibility issues with automation, following WCAG guidelines. |
| 6 | +keywords: |
| 7 | + - LambdaTest |
| 8 | + - Accessibility |
| 9 | + - Testing |
| 10 | + - Automation |
| 11 | + - Accessibility Testing Settings |
| 12 | +url: https://www.lambdatest.com/support/docs/accessibility-android-test/ |
| 13 | +site_name: LambdaTest |
| 14 | +slug: accessibility-android-test/ |
| 15 | +--- |
| 16 | + |
| 17 | +import CodeBlock from '@theme/CodeBlock'; |
| 18 | +import {YOUR_LAMBDATEST_USERNAME, YOUR_LAMBDATEST_ACCESS_KEY} from "@site/src/component/keys"; |
| 19 | +import Tabs from '@theme/Tabs'; |
| 20 | +import TabItem from '@theme/TabItem'; |
| 21 | + |
| 22 | +<script type="application/ld+json" |
| 23 | + dangerouslySetInnerHTML={{ __html: JSON.stringify({ |
| 24 | + "@context": "https://schema.org", |
| 25 | + "@type": "BreadcrumbList", |
| 26 | + "itemListElement": [{ |
| 27 | + "@type": "ListItem", |
| 28 | + "position": 1, |
| 29 | + "name": "Home", |
| 30 | + "item": "https://www.lambdatest.com" |
| 31 | + },{ |
| 32 | + "@type": "ListItem", |
| 33 | + "position": 2, |
| 34 | + "name": "Support", |
| 35 | + "item": "https://www.lambdatest.com/support/docs/" |
| 36 | + },{ |
| 37 | + "@type": "ListItem", |
| 38 | + "position": 3, |
| 39 | + "name": "Accessibility Android Test", |
| 40 | + "item": "https://www.lambdatest.com/support/docs/accessibility-android-test/" |
| 41 | + }] |
| 42 | + }) |
| 43 | + }} |
| 44 | +></script> |
| 45 | + |
| 46 | +This guide walks you through automating accessibility testing of a native Android app using **LambdaTest's Accessibility Automation Tool (Beta) via Appium**. You'll run an automated accessibility scan on a real Android device hosted on LambdaTest’s real device cloud infrastructure. |
| 47 | + |
| 48 | +## Prerequisites |
| 49 | + |
| 50 | +- Your [LambdaTest Username and Access key](/support/docs/using-environment-variables-for-authentication-credentials/) |
| 51 | +- Python 3.x or Java JDK 8+ installed |
| 52 | +- Appium Python Client or Java Client Library |
| 53 | + |
| 54 | +## Step-by-Step Guide to Trigger Your Test |
| 55 | + |
| 56 | +### Step 1: Setup Your Test Suite |
| 57 | + |
| 58 | +You can use your own project to configure and test it. For demo purposes, we are using the sample repository. |
| 59 | + |
| 60 | +:::tip sample repo |
| 61 | +Download or Clone the code sample from the LambdaTest GitHub repository to run your tests. |
| 62 | + |
| 63 | +<a href="https://github.com/LambdaTest/lambdatest-accessibility-selenium" className="github__anchor"><img loading="lazy" src={require('../assets/images/icons/github.png').default} alt="Image" className="doc_img"/> View on GitHub</a> |
| 64 | +::: |
| 65 | + |
| 66 | +If you are using your own project, make sure you update the **Hub endpoint** in your tests file. By setting up the Hub endpoint, you establish the communication channel between your tests and the browser nodes, enabling effective test distribution and execution. |
| 67 | + |
| 68 | +Configure the desired capabilities based on your test requirements. For example: |
| 69 | + |
| 70 | +<Tabs className="docs__val"> |
| 71 | + |
| 72 | +<TabItem value="python" label="Python" default> |
| 73 | + |
| 74 | + <div className="lambdatest__codeblock"> |
| 75 | + |
| 76 | + ```python |
| 77 | + desired_cap = { |
| 78 | + "platform": "android", |
| 79 | + "isRealMobile": True, |
| 80 | + "app": "lt://APP", # Replace with your LambdaTest App URL |
| 81 | + "accessibility": True, |
| 82 | + "buildName": "Accessibility-lambda", |
| 83 | + "idleTimeout": 1800, |
| 84 | + "build": "NewAppiumBuild", |
| 85 | + "name": "MyTest", |
| 86 | + "devicelog": True |
| 87 | + } |
| 88 | + ``` |
| 89 | + |
| 90 | + </div> |
| 91 | + |
| 92 | +</TabItem> |
| 93 | + |
| 94 | +<TabItem value="java" label="Java" default> |
| 95 | + |
| 96 | + <div className="lambdatest__codeblock"> |
| 97 | + ```java |
| 98 | + DesiredCapabilities caps = new DesiredCapabilities(); |
| 99 | + caps.setCapability("platform", "android"); |
| 100 | + caps.setCapability("isRealMobile", true); |
| 101 | + caps.setCapability("app", "lt://APPID"); // Replace with your App ID |
| 102 | + caps.setCapability("accessibility", true); |
| 103 | + caps.setCapability("idleTimeout", 1800); |
| 104 | + caps.setCapability("build", "AccessibilityScanBuild"); |
| 105 | + caps.setCapability("name", "MyTest"); |
| 106 | + caps.setCapability("devicelog", true); |
| 107 | + ``` |
| 108 | +</div> |
| 109 | + |
| 110 | +</TabItem> |
| 111 | +</Tabs> |
| 112 | + |
| 113 | + |
| 114 | +> You can generate capabilities for your test requirements with the help of our inbuilt 🔗 [Capabilities Generator Tool](https://www.lambdatest.com/capabilities-generator/). |
| 115 | +
|
| 116 | +### Step 2: Establish User Authentication |
| 117 | + |
| 118 | +Now, you need to export your environment variables *LT_USERNAME* and *LT_ACCESS_KEY* that are available in the [LambdaTest Profile page](https://accounts.lambdatest.com/detail/profile). |
| 119 | + |
| 120 | +Run the below mentioned commands in your terminal to setup the CLI and the environment variables. |
| 121 | + |
| 122 | +<Tabs className="docs__val"> |
| 123 | + |
| 124 | +<TabItem value="bash" label="Linux / MacOS" default> |
| 125 | + |
| 126 | + <div className="lambdatest__codeblock"> |
| 127 | + <CodeBlock className="language-bash"> |
| 128 | + {`export LT_USERNAME="${ YOUR_LAMBDATEST_USERNAME()}" |
| 129 | +export LT_ACCESS_KEY="${ YOUR_LAMBDATEST_ACCESS_KEY()}"`} |
| 130 | + </CodeBlock> |
| 131 | +</div> |
| 132 | + |
| 133 | +</TabItem> |
| 134 | + |
| 135 | +<TabItem value="powershell" label="Windows" default> |
| 136 | + |
| 137 | + <div className="lambdatest__codeblock"> |
| 138 | + <CodeBlock className="language-powershell"> |
| 139 | + {`set LT_USERNAME="${ YOUR_LAMBDATEST_USERNAME()}" |
| 140 | +set LT_ACCESS_KEY="${ YOUR_LAMBDATEST_ACCESS_KEY()}"`} |
| 141 | + </CodeBlock> |
| 142 | +</div> |
| 143 | + |
| 144 | +</TabItem> |
| 145 | +</Tabs> |
| 146 | + |
| 147 | +### Step 3: Execute and Monitor your Test |
| 148 | + |
| 149 | +Now execute your tests and visit the [Automation Dashboard](https://accounts.lambdatest.com/dashboard). Click on the Accessibility tab and check the report generated. |
| 150 | + |
| 151 | +```bash |
| 152 | +mvn test |
| 153 | +``` |
| 154 | + |
| 155 | +<img loading="lazy" src={require('../assets/images/accessibility-testing/accessibility-automation.png').default} alt="automation-dashboard" className="doc_img"/> |
0 commit comments