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. |
Roku TV (RokuOS 14.6)
For Roku TV, we utilize the robust capabilities of the Appium Roku driver. This driver allows you to interact with Roku devices using a comprehensive set of commands. Roku’s External Control Protocol (ECP) uses string literals for key presses, not numeric KeyCodes
like Android.
Button | Key Value (for pressKey) | Behaviour |
---|---|---|
Back | Back |
Takes you back to the previous screen or menu. |
Home | Home |
Takes you back to the Roku home screen. |
Select (OK) | Select |
Selects the UI item that currently has focus. |
Up (D-Pad) | Up |
Moves the focus upward in the UI. |
Down (D-Pad) | Down |
Moves the focus downward in the UI. |
Left (D-Pad) | Left |
Moves the focus left in the UI. |
Right (D-Pad) | Right |
Moves the focus right in the UI. |
Play/Pause | Play |
Toggles media playback between play and pause. |
Rewind | Rev |
Rewinds or skips backward in media playback contexts. |
Fast Forward | Fwd |
Fast Forwards or skips ahead in media playback contexts. |
Instant Replay | InstantReplay |
Skips backward a short duration (e.g., 7 seconds). |
Options / Star (*) | Info |
Opens a context-specific options menu for the focused item. |
Power On | PowerOn |
Turns the TV on (for supported Roku TV models). |
Power Off | PowerOff |
Turns the TV off (for supported Roku TV models). |
For a detailed list of supported commands and their usage, you can refer to the official documentation Appium Roku driver on GitHub.
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
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!