Tizen WebDriver
Introduction
This page is a reference for the available commands, execute methods, and key mappings for the Tizen WebDriver integration.
The Tizen WebDriver integration is written by TV Labs for Samsung Tizen televisions. It is an Appium compatible WebDriver, so it can be driven from any Appium or WebDriver client. It debug-launches the app and drives its page through a ChromeDriver attached to the app's web inspector. Tizen 4.0 and older are also supported, through the app's WebKit inspector; see Tizen 4.0 and older.
Starting a Session
Select a build with the tvlabs:build capability and it is sideloaded onto the TV and launched when the session starts. To launch an app that is already installed, name it with appium:appPackage instead.
const capabilities = {
'tvlabs:constraints': { platform_key: 'tizen' },
'tvlabs:build': 'YOUR_BUILD_ID',
};
When a session starts:
- The app is closed if it is already running, so every session attaches to a fresh page.
- The app is launched in debug mode, which opens its web inspector.
- ChromeDriver attaches to the app's page once it appears on the inspector.
A session started without an app is still a valid session. ChromeDriver attaches to whatever page is already being debugged, if any.
When the session ends, the app is closed.
Capabilities
| Capability | Description |
|---|---|
appium:appPackage | The ID of the app to launch. Set for you from tvlabs:build when a build is selected |
goog:chromeOptions | Passed through to ChromeDriver. debuggerAddress is always set by TV Labs |
appium:appId is not read on Tizen. Use appium:appPackage.
Tizen 4.0 and older
Tizen 4.0 and older ship a browser engine too old for ChromeDriver, so on these TVs TV Labs drives the page directly through the app's WebKit inspector instead. Sessions start the same way, and no capabilities change. Finding elements, element commands, navigation, cookies, and script execution work the same way. W3C Actions, element screenshots, alerts, and printing are not available.
The session is attached to the page of the app it launched. Closing the app, or pressing a key that leaves it, ends that page, and the commands that follow fail. To relaunch the app and keep the session, use tizen: activateApp with debug: true. See ChromeDriver session lifecycle.
Available Commands
The standard W3C WebDriver commands for the document, navigation, finding elements, element state, interaction, cookies, and synchronous and asynchronous script execution are proxied to ChromeDriver, so their availability depends on the TV's Chromium version.
The id, name, and class name locator strategies are translated to CSS selectors. accessibility id is not supported.
The following behave differently on Tizen:
| Command | Behavior on Tizen |
|---|---|
takeScreenshot | Served from the TV Labs video capture of the device, so it shows the whole screen |
getContexts | Always the single NATIVE_APP context. DOM commands already run against the page |
switchContext | Not supported |
switchToFrame | Only null (the top-level document) is supported. iframes can't be entered |
getWindowHandles | Always a single window. Resizing, maximizing, and fullscreen leave the window as is |
Execute Methods
In addition to the standard WebDriver commands, the following execute methods are available for device interaction:
| Command | Required Arguments | Description |
|---|---|---|
tizen: pressKey | key | Press a key in the app. See tizen: pressKey. |
tizen: longPressKey | key | Hold a key in the app. Holds for one second unless duration is given, in milliseconds. |
tizen: activateApp | appPackage | Launch an installed app. See tizen: activateApp. |
tizen: terminateApp | pkgId | Close a running app. |
tizen: listApps | - | List the installed apps, as objects with appName and appPackage. |
tizen: clearApp | - | Clear the app's local storage and reload the page. |
mobile: listApps | - | The same as tizen: listApps. |
mobile: deviceInfo | - | See mobile: deviceInfo. |
tizen: pressKey
await driver.executeScript('tizen: pressKey', [{ key: 'KEY_DOWN' }]);
// Hold the key for two seconds
await driver.executeScript('tizen: pressKey', [{ key: 'KEY_ENTER', duration: 2000 }]);
Keys are dispatched as KeyboardEvents inside the app's page, holding the key for duration milliseconds (200 by default). They are not remote control presses, so they only reach the app: keys such as Home and Power, which have no web equivalent, are not available.
tizen: activateApp
// Relaunch the app and re-attach the session to its new page
await driver.executeScript('tizen: activateApp', [{ appPackage: 'AbCdEfGhIj.MyApp', debug: true }]);
With debug: true, the app is closed, relaunched in debug mode, and the session is re-attached to its new page. The session ID stays the same, but element references from before the relaunch are no longer valid.
Without debug, the app is launched normally and the session stays attached to the page it had before, so DOM commands fail if that page is gone.
Key Map
The following keys are available with tizen: pressKey and tizen: longPressKey. Names are case-sensitive.
| Key | Description |
|---|---|
KEY_UP | Up |
KEY_DOWN | Down |
KEY_LEFT | Left |
KEY_RIGHT | Right |
KEY_ENTER | OK / Enter |
KEY_RETURN | Back |
KEY_EXIT | Exit |
KEY_0 … KEY_9 | Digits |
KEY_PLAY | Play |
KEY_PAUSE | Pause |
KEY_STOP | Stop |
KEY_REWIND | Rewind |
KEY_FF | Fast forward |
KEY_REC | Record |
KEY_VOLUP | Volume Up |
KEY_VOLDOWN | Volume Down |
KEY_MUTE | Mute |
KEY_CHUP | Channel Up |
KEY_CHDOWN | Channel Down |
KEY_PRECH | Previous Channel |
KEY_CH_LIST | Channel List |
KEY_RED | Red |
KEY_GREEN | Green |
KEY_YELLOW | Yellow |
KEY_BLUE | Blue |
KEY_MENU | Menu |
KEY_TOOLS | Tools |
KEY_INFO | Info |
KEY_GUIDE | Guide |
KEY_SOURCE | Source |
KEY_PICTURE_SIZE | Picture Size |
KEY_HELP | E-Manual |
KEY_MTS | MTS |
KEY_CAPTION | Caption |
KEY_TTX_MIX | Teletext |