For AI agents and LLMs: a machine-readable index is available at llms.txt. A plain-Markdown version of any documentation page is available by appending .md to its URL.
Skip to main content
Real Device

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.

Plus Plan Feature

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:

  1. Set up an environment for testing your Apps using Android TV with Appium.
  2. Understand and configure the core capabilities required for your Appium test suite.
  3. 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 ModelPlatform Version
Nvidia Shield TVAndroid 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.

Verified
export LT_USERNAME=YOUR_LAMBDATEST_USERNAME \
export 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:

Verified
curl -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"

cmd

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
  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:

CapabilityValueWhat it does
platformNameandroidtvRuns the test on an Android TV device instead of a phone or tablet.
deviceNameNvidia Shield TVPicks the device model from Supported Models.
platformVersion11Sets the Android version of that device.
isRealMobiletrueRuns the test on a real device.
privateCloudtrueFetches the device from your organization's Private Cloud, which Android TV automation needs.
automationNameUiAutomator2Uses the UiAutomator2 automation engine, which also sends the D-pad key events shown below.
w3ctrueMakes Appium use the W3C WebDriver protocol.
applt://APP_IDPoints to the app you uploaded in step 2.
appPackageorg.smarttube.stableOptional. Names the package of the app to start.

Shown below is an execution snapshot from TestMu AI Dashboard:

cmd


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 buttonAndroid key codeValue
UpKEYCODE_DPAD_UP19
DownKEYCODE_DPAD_DOWN20
LeftKEYCODE_DPAD_LEFT21
RightKEYCODE_DPAD_RIGHT22
Select (center)KEYCODE_DPAD_CENTER23
BackKEYCODE_BACK4
HomeKEYCODE_HOME3

In your test, press the keys in the order a viewer would:

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

Help and Support

Related Articles