How to Automate Android TV Apps on TestMu AI
Automated smart TV testing on TestMu AI runs your Appium scripts against real Android TV devices in the cloud, such as the Nvidia Shield TV on Android 11. This page shows how to upload your app, set the Android TV capabilities and send D-pad key events, so you can check remote-based navigation and app behavior in automated runs.
This feature is available exclusively with the Private Cloud Plan.
To unlock this feature, purchase or upgrade to the required plan. If you need assistance, please contact your TestMu AI support representative, reach out to our [24×7 Chat Support], or email us at support@testmuai.com.
Objective
By the end of this topic, you will be able to:
- Set up an environment for testing your Apps using Android TV with Appium.
- Understand and configure the core capabilities required for your Appium test suite.
- Explore the advanced features of TestMu AI.
Prerequisites
Before you can start performing App automation testing with Appium, you would need to follow these steps:
- You have access to TestMu AI username and accessKey. If you have not registered yet, you can do the same by visiting our website. You will be able to access the credentials in the TestMu AI Profile
- Install the latest Python build from the official website. We recommend using the latest version.
- Make sure pip is installed in your system. You can install pip from pip documentation.
Supported Models
| Device Model | Platform Version |
|---|---|
| Nvidia Shield TV | Android 11 |
Run Your First Test
1. Set Up Authentication
Make sure you have your TestMu AI credentials with you to run test automation scripts on TestMu AI. To obtain your access credentials, purchase a plan or access the Automation Dashboard. Then, set TestMu AI Username and Access Key in environment variables with following commands.
- Linux / MacOS
- Windows
export LT_USERNAME=YOUR_LAMBDATEST_USERNAME \
export LT_ACCESS_KEY=YOUR_LAMBDATEST_ACCESS_KEY
set LT_USERNAME=YOUR_LAMBDATEST_USERNAME `
set LT_ACCESS_KEY=YOUR_LAMBDATEST_ACCESS_KEY
2. Upload your application
Upload your Android TV application (.ipa file) to the TestMu AI 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. Here is an example cURL request to upload your app using our REST API:
Using App File from System:
Verifiedcurl -u "$LT_USERNAME:$LT_ACCESS_KEY" -X POST "https://manual-api.lambdatest.com/app/upload/realDevice" -F "appFile=@smarttube_stable.apk" -F "name=androidtv_app" -F "type=androidtv"

3. Configure Desired Capabilities
In your automation script, set up the platform capability to specify that you are testing on an Android TV device.
Verified- Java
DesiredCapabilities capabilities = new DesiredCapabilities();
HashMap<String, Object> ltOptions = new HashMap<String, Object>();
ltOptions.put("build", "Android TV Demo");
ltOptions.put("name", "Android TV Demo");
ltOptions.put("deviceName", "Nvidia Shield TV");
ltOptions.put("platformVersion", "11");
ltOptions.put("platformName", "androidtv");
ltOptions.put("isRealMobile", true);
ltOptions.put("privateCloud", true);
ltOptions.put("w3c", true);
ltOptions.put("automationName", "UiAutomator2");
ltOptions.put("app", "lt://APP_ID");
/* Optional Capability */
/* ltOptions.put("appPackage", "org.smarttube.stable"); */
capabilities.setCapability("LT:Options", ltOptions);
What each Android TV capability in the block above does:
| Capability | Value | What it does |
|---|---|---|
platformName | androidtv | Runs the test on an Android TV device instead of a phone or tablet. |
deviceName | Nvidia Shield TV | Picks the device model from Supported Models. |
platformVersion | 11 | Sets the Android version of that device. |
isRealMobile | true | Runs the test on a real device. |
privateCloud | true | Fetches the device from your organization's Private Cloud, which Android TV automation needs. |
automationName | UiAutomator2 | Uses the UiAutomator2 automation engine, which also sends the D-pad key events shown below. |
w3c | true | Makes Appium use the W3C WebDriver protocol. |
app | lt://APP_ID | Points to the app you uploaded in step 2. |
appPackage | org.smarttube.stable | Optional. Names the package of the app to start. |
Shown below is an execution snapshot from TestMu AI Dashboard:

Navigate With D-pad Key Events
An Android TV app is driven by its remote, so most steps in a TV test move focus with the D-pad and then select the focused item. Appium sends each remote button as an Android key event through the UiAutomator2 driver. These are the key codes from the Android KeyEvent reference:
| Remote button | Android key code | Value |
|---|---|---|
| Up | KEYCODE_DPAD_UP | 19 |
| Down | KEYCODE_DPAD_DOWN | 20 |
| Left | KEYCODE_DPAD_LEFT | 21 |
| Right | KEYCODE_DPAD_RIGHT | 22 |
| Select (center) | KEYCODE_DPAD_CENTER | 23 |
| Back | KEYCODE_BACK | 4 |
| Home | KEYCODE_HOME | 3 |
In your test, press the keys in the order a viewer would:
- Java
- Python
import io.appium.java_client.android.nativekey.AndroidKey;
import io.appium.java_client.android.nativekey.KeyEvent;
// driver is the AndroidDriver session started with the capabilities above
driver.pressKey(new KeyEvent(AndroidKey.DPAD_DOWN)); // move focus down one row
driver.pressKey(new KeyEvent(AndroidKey.DPAD_RIGHT)); // move focus to the next tile
driver.pressKey(new KeyEvent(AndroidKey.DPAD_CENTER)); // select the focused item
driver.pressKey(new KeyEvent(AndroidKey.BACK)); // go back one screen
# driver is the Appium session started with the capabilities above
driver.press_keycode(20) # KEYCODE_DPAD_DOWN: move focus down one row
driver.press_keycode(22) # KEYCODE_DPAD_RIGHT: move focus to the next tile
driver.press_keycode(23) # KEYCODE_DPAD_CENTER: select the focused item
driver.press_keycode(4) # KEYCODE_BACK: go back one screen