Raspberry Pi 3 based Android Tv automation using Appium.

Nitin Verma
2 min readMay 22, 2020

In this post we will go through with raspberry pi 3 android Tv automation.

What is Android TV?

Android TV is a version of the Android operating system designed for digital media players, set-top boxes, soundbars, and TVs and developed by Google. Users can stream content to TV via apps, both free and paid, using your internet connection. Android TV almost certainly supports it. Netflix, HBO Now, Showtime Anytime, YouTube, Spotify and Hulu.

What is Raspberry pi?

It’s a powerful credit-card sized single board computer can be used for many applications and supersedes the original Raspberry Pi Model B.

Raspberry Pi 3 B

I have installed LineageOS on Raspberry Pi which gives the benefit of the Android operating system. And after connecting to the TV using HDMI cable and powered ON, android Tv will look like as shown below.

Raspberry pi 3 Android TV user interface

Generally Android TV app development is somewhat very similar to the Android mobile app development in some ways. For automating Android TV app we use any of the broadly available native frameworks for Android mobile testing.

· Appium

· Coffee

· Detox

· Calabash

· UI Automator

· Robotium

How to automated Android TV using Appium?

protected static ThreadLocal<AppiumDriver> tlDriver = new ThreadLocal<>();private static AndroidDriver androidDriver;DesiredCapabilities capabilities = new DesiredCapabilities();capabilities.setCapability(MobCapabilityType.PLATFORM_NAME.getValue(), Constants.ANDROID);
capabilities.setCapability(MobCapabilityType.PLATFORM_VERSION.getValue(), platformVersion);
capabilities.setCapability(MobCapabilityType.DEVICE_NAME.getValue(), deviceName);
capabilities.setCapability(MobCapabilityType.APP_ACTIVITY.getValue(), activityName);
capabilities.setCapability(MobCapabilityType.APP_PACKAGE.getValue(), packageName);
capabilities.setCapability("autoGrantPermissions", "true");
capabilities.setCapability(MobCapabilityType.AUTOMATION_NAME.getValue(),"UiAutomator2");

capabilities.setCapability("uiautomator2ServerInstallTimeout", 90000);
capabilities.setCapability(MobCapabilityType.NEW_COMMAND_TIMEOUT.getValue(), commandTimeOut);capabilities.setCapability("noReset", true);tlDriver.set(new AndroidDriver(new URL("http://127.0.0.1:" + port + "/wd/hub"), capabilities));androidDriver = (AndroidDriver) tlDriver.get();

tlDriver.get().manage().timeouts().implicitlyWait(implicitTimeOut, TimeUnit.SECONDS);

Below is the of video for end to end Test script execution.

Execution extent report.

Extent report

Thank you!!

--

--