Skip to main content

Use Remote Control Navigation

Since smart TV devices don’t have a touch screen and user interaction happens via a remote control, remote control navigation becomes a primary feature for smart TV apps. Also, not all elements in the app have unique identifiers and those elements can be accessed via remote control navigation only.

Android TV (Fire TV/ Nvidia Shield)

Android keycodes can be used to control Amazon Fire TV Stick/ Nvidia Shield remote buttons. We can call the pressKey method (with the relevant keycode) to press any remote control button.

Example:

driver.pressKey(new KeyEvent(AndroidKey.DPAD_DOWN)); //Press DPAD_DOWN
driver.pressKey(new KeyEvent(AndroidKey.DPAD_RIGHT)); //Press DPAD_RIGHT
driver.pressKeycode(20); //Press DPAD_DOWN
driver.pressKeycode(22); //Press DPAD_RIGHT
driver.press_keycode(20) # DPAD_DOWN
driver.press_keycode(22) # DPAD_RIGHT

Here is a complete list of Fire TV/Nvidia Shield Remote buttons mapping:

KeyCode Button KeyEvent Behaviour
4 Back KEYCODE_BACK Return the user to the previous operation or screen (Activity).
82 Menu KEYCODE_MENU Invoke the Android context menu (OptionsMenu)
23 Select (D-Pad Center) KEYCODE_DPAD_CENTER Select the user interface item with the current focus.
19 Up (D-Pad) KEYCODE_DPAD_UP Move the focus upward in the user interface.
20 Down (D-Pad) KEYCODE_DPAD_DOWN Move the focus downward in the user interface.
21 Left (D-Pad) KEYCODE_DPAD_LEFT Move the focus left in the user interface.
22 Right (D-Pad) KEYCODE_DPAD_RIGHT Move the focus right in the user interface.
85 Play/Pause KEYCODE_MEDIA_PLAY_PAUSE Control media playback. Play/Pause is a toggle.
89 Rewind KEYCODE_MEDIA_REWIND Rewind or skip backwards in media playback contexts.
90 Fast Forward KEYCODE_MEDIA_FAST_FORWARD Fast Forward or skip ahead in media playback contexts.

TvOS (Apple TV 4k)

Appium provides Buttons actions via mobile: pressButton to perform remote controller based actions.

Example:

driver.executeScript("mobile: pressButton", ImmutableMap.of("name", "Home"));
driver.executeScript("mobile: pressButton", ImmutableMap.of("name", "Up"));
await driver.execute('mobile: pressButton', {name: 'Home'});
await driver.execute('mobile: pressButton', {name: 'Up'});
@driver.execute_script 'mobile: pressButton', { name: 'Home' }
@driver.execute_script 'mobile: pressButton', { name: 'Up' }

Here is a complete list of Apple TV Remote buttons mapping:

Button Name Behaviour
Home Return the user to the home screen (Activity).
Menu Return the user to the previous operation or screen (Activity). menu button works as a back for iOS context in tvOS.
Select Select the user interface item with the current focus.
Up Move the focus upward in the user interface.
Down Move the focus downward in the user interface.
Left Move the focus left in the user interface.
Right Move the focus right in the user interface.
Play/Pause Control media playback. Play/Pause is a toggle.

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