Skip to main content

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:

  1. The app is closed if it is already running, so every session attaches to a fresh page.
  2. The app is launched in debug mode, which opens its web inspector.
  3. 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​

CapabilityDescription
appium:appPackageThe ID of the app to launch. Set for you from tvlabs:build when a build is selected
goog:chromeOptionsPassed 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.

note

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:

CommandBehavior on Tizen
takeScreenshotServed from the TV Labs video capture of the device, so it shows the whole screen
getContextsAlways the single NATIVE_APP context. DOM commands already run against the page
switchContextNot supported
switchToFrameOnly null (the top-level document) is supported. iframes can't be entered
getWindowHandlesAlways 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:

CommandRequired ArgumentsDescription
tizen: pressKeykeyPress a key in the app. See tizen: pressKey.
tizen: longPressKeykeyHold a key in the app. Holds for one second unless duration is given, in milliseconds.
tizen: activateAppappPackageLaunch an installed app. See tizen: activateApp.
tizen: terminateApppkgIdClose 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.

KeyDescription
KEY_UPUp
KEY_DOWNDown
KEY_LEFTLeft
KEY_RIGHTRight
KEY_ENTEROK / Enter
KEY_RETURNBack
KEY_EXITExit
KEY_0 … KEY_9Digits
KEY_PLAYPlay
KEY_PAUSEPause
KEY_STOPStop
KEY_REWINDRewind
KEY_FFFast forward
KEY_RECRecord
KEY_VOLUPVolume Up
KEY_VOLDOWNVolume Down
KEY_MUTEMute
KEY_CHUPChannel Up
KEY_CHDOWNChannel Down
KEY_PRECHPrevious Channel
KEY_CH_LISTChannel List
KEY_REDRed
KEY_GREENGreen
KEY_YELLOWYellow
KEY_BLUEBlue
KEY_MENUMenu
KEY_TOOLSTools
KEY_INFOInfo
KEY_GUIDEGuide
KEY_SOURCESource
KEY_PICTURE_SIZEPicture Size
KEY_HELPE-Manual
KEY_MTSMTS
KEY_CAPTIONCaption
KEY_TTX_MIXTeletext