Skip to main content
No Result Found
Get your setup working faster. Join our Discord for optimisation tips from elite testers. Join our DiscordJoin our Discord

Run your Appium tests on smart TV devices

A quickstart guide to running your Appium tests on smart TV devices with BrowserStack App Automate.

App Automate lets you test your apps on smart TVs. BrowserStack currently supports testing apps on the following smart TVs:

  • Amazon Fire TV Stick 4K (Android 7.1)
  • Nvidia Shield TV Pro 2019 (Android 11.0)
  • Apple TV 4K (tvOS 26)
  • Roku TV (RokuOS v15+). Roku TV requires Appium version 2.18.0. For details on the interactions you can perform with Roku devices, see the Appium Roku Driver documentation on GitHub. Roku has two types of devices, Roku Ultra and Roku Express 4K. You can define any one of them.
  • Roku devices on the BrowserStack platform are automatically updated with the latest official firmware versions as soon as they become available. You do not need to manually request or manage device updates. The platform maintains current software versions across all Roku devices to ensure optimal testing performance and feature compatibility.
  • Network logs and local are not directly supported for Roku devices. To have these features enabled, contact support.

Onboard faster with Test Companion

Launch in your IDE. Chat with the AI assistant to configure and run your first build instantly.

Launch in IDE

Prerequisites

Before you start, make sure you have the following:

  • Access to the smart TV alpha release on your BrowserStack account. To request access, contact support.
  • A BrowserStack username and access key. To get your credentials, sign up for a free trial or purchase a plan.
  • A smart TV app file — .apk for Android-based TVs (Fire TV, Nvidia Shield), .ipa for Apple TV, or .zip for Roku TV.

Upload your app

Sample apps for different smart TV devices:

  1. Android-based smart TVs (Fire TV, Nvidia Shield): Download the sample app for Android.
  2. Apple TV: Download the sample app for tvOS.
  3. Roku TV: Download the sample app for Roku TV.

Upload your app file (.apk for Android-based smart TVs, .ipa for Apple TV, or .zip for Roku TV) to BrowserStack servers using one of the following methods:

On the App Automate dashboard, click the Upload button on the top-right corner. Select the app you want to upload from your filesystem.

The Upload button in the top-right corner of the App Automate dashboard

To upload an app using the App Management UI, follow these steps:

  1. Navigate to the App Automate dashboard. On the sidebar, click App Management.
  2. On the App Management UI, click Upload App.
  3. Select the app you want to upload from your filesystem. To upload the app using a public URL, paste the URL of your app in the or upload from URL box.
  4. After selecting the app, choose the App Automate framework you want to use for testing. You can optionally add flags and a custom ID.
  5. Click Upload. The app is uploaded to the BrowserStack servers, and you receive an App ID that you can use to run tests.

Upload apps from the filesystem using App Management UI

To manage your apps, see the documentation on managing apps using App Management UI.

To upload an app from your filesystem or a public URL using the REST API, run the following cURL command:

curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/upload" \
-F "file=@/path/to/app/file"

# Ensure that `@` symbol is prepended to the file path in the request.

A sample response is as follows:

{
    "app_url":"bs://j3c874f21852ba57957a3fdc33f47514288c4ba4"
}

Save the app_url value from the response. You use it in the next step to specify which app to test.

App upload might take a few seconds to about a minute depending on the size of your app. Do not interrupt the cURL command until you get the response in your command-line/terminal.

Configure your Appium capabilities

Configure your Appium test script with the following capabilities to target a BrowserStack smart TV device:

  • Set the app capability to the app_url of the app you uploaded.
  • Set the device capability to one of the following:
    • Amazon Fire TV Stick 4K — to run tests on Fire TV
    • Nvidia Shield TV Pro 2019 — to run tests on Nvidia Shield TV
    • Apple TV 4K — to run tests on Apple TV
    • Roku TV — to run tests on Roku TV (RokuOS v15+)
  • For Apple TV, also set automationName to xcuitest and platformName to tvos.
  • Initialize an Appium driver using a remote BrowserStack hub URL along with your BrowserStack credentials:
https://YOUR_USERNAME:YOUR_ACCESS_KEY@hub-cloud.browserstack.com/wd/hub

Run a sample test script

Choose your target device, then select your preferred language (Java, Ruby, Node.js, or Python) to view a complete sample test script with the required device capabilities:

import io.appium.java_client.AppiumBy;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.nativekey.AndroidKey;
import io.appium.java_client.android.nativekey.KeyEvent;
import io.appium.java_client.android.options.UiAutomator2Options;
import org.openqa.selenium.By;
import org.openqa.selenium.MutableCapabilities;
import io.appium.java_client.android.AndroidDriver;
import java.net.URL;
import static org.openqa.selenium.By.*;

public class SmartTVTest {

    public void testSmartTV() throws Exception {
        AndroidDriver driver;

        MutableCapabilities caps = new UiAutomator2Options();
        caps.setCapability("build", "Smart TV Test");
        caps.setCapability("deviceName", "Amazon Fire TV Stick 4K");
        caps.setCapability("osVersion", "7.1");
        caps.setCapability("appium:browserstack.dedicatedDevice", true);
        caps.setCapability("app", APP_ID);

        driver = new AndroidDriver(new URL("https://" +
                BROWSERSTACK_USER + ":" + BROWSERSTACK_ACCESS_KEY +
                "@hub.browserstack.com/wd/hub"), caps);


        Thread.sleep(5000);
        driver.pressKey(new KeyEvent().withKey(AndroidKey.DPAD_CENTER));
        Thread.sleep(5000);
        driver.pressKey(new KeyEvent().withKey(AndroidKey.DPAD_LEFT));
        Thread.sleep(5000);
        driver.pressKey(new KeyEvent().withKey(AndroidKey.DPAD_LEFT));
        Thread.sleep(5000);
        driver.pressKey(new KeyEvent().withKey(AndroidKey.DPAD_RIGHT));
        Thread.sleep(5000);
        driver.pressKey(new KeyEvent().withKey(AndroidKey.DPAD_RIGHT));
        Thread.sleep(5000);
        driver.pressKey(new KeyEvent().withKey(AndroidKey.DPAD_RIGHT));
        Thread.sleep(5000);
        driver.pressKey(new KeyEvent().withKey(AndroidKey.DPAD_RIGHT));
        Thread.sleep(5000);
        driver.pressKey(new KeyEvent().withKey(AndroidKey.DPAD_CENTER));
        Thread.sleep(5000);
        driver.pressKey(new KeyEvent().withKey(AndroidKey.DPAD_RIGHT));

        Thread.sleep(5000);
        driver.pressKey(new KeyEvent().withKey(AndroidKey.DPAD_CENTER));
        Thread.sleep(5000);
        driver.pressKey(new KeyEvent().withKey(AndroidKey.DPAD_CENTER));
        Thread.sleep(10000);
        driver.pressKey(new KeyEvent().withKey(AndroidKey.MEDIA_PLAY_PAUSE));

        driver.quit();
    }
}

View test execution results

After your tests start running, view results on the App Automate dashboard.

Open a specific test session to see execution details and debugging information, including video recordings, screenshots, and Appium logs.

You can also fetch results programmatically using the REST API.

Frequently asked questions

This behavior is expected. The Appium driver closes the app when you call start_driver. To reopen the app, call activateApp at the start of your script:

Ruby
Copy icon Copy

Need help?

If you have any questions, contact support.

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback!

Talk to an Expert
Download Copy Check Circle