0.11.3 • Published 6 days ago

@dlenroc/appium-roku-driver v0.11.3

Weekly downloads
-
License
MIT
Repository
github
Last release
6 days ago

Appium Roku Driver · NPM Version Node.js Version Node.js CI

Roku Driver is a WebDriver that allows testing channels/screensavers using any webdriver client.

Prerequisites

Installation

appium driver install --source npm @dlenroc/appium-roku-driver

Documentation

Thanks to the Appium and WebDriver protocol, this driver works just like other web drivers, but there are a couple of things worth mentioning.

Initialization

Like other drivers, roku-driver by default uses the so-called fast reset algorithm, in which registries are cleared before each test, and a full reinstallation occurs only if the channel differs from the one already installed.

Locators

The following location strategies are supported: tag name, link text, partial link text, css selector and xpath.

Contexts

  • ECP (default) External Control Protocol is a context that finds elements quickly, but does not see many attributes.

  • ODC (WIP) On Device Component is a context that finds elements slower, but see all attributes. (can be tunned using elementResponseAttributes setting).

Deep linking

  • input - Sends a custom event to the launched channel.

    driver.url('roku://input?<key>=<value>');
  • launch - Launches given channel with specific arguments.

    driver.url('roku://launch/:channel_id?<key>=<value>');

Channels

In roku appId is always dev for sideloaded channel or a number for channels installed from store (ex: 12 for Netflix).

driver.queryAppState('dev');
driver.queryAppState('12');

Note: most commands only work with SceneGrapth based sideloaded channels.

Screensaver / Screensaver Settings

Given driver allows testing of Screensavers via appium:entryPoint capability.

  • channel (default) - Opens channel itself.
  • screensaver - Opens your channel screen saver.
  • screensaver-settings - Opens your channel screen saver settings.

Note: Usually screensavers open on their own and close immediately after any user input is sent, but when entryPoint screensaver is used, it runs in the context of the channel, so the input interaction does not close it (BACK and HOME buttons are an exception).

Registries / Arguments

In Roku world:

So, knowing this, we can significantly speed up the automation by skipping authorization/configuration steps.

Note: appium:arguments and appium:registry will contain different values in your case.

const capabilities = {
  ...commonCapabilities,

  // Launch parameters
  'appium:arguments': {
    contentId: 1234,
    mediaType: 'movie',
  },

  // Registry sections Settings
  'appium:registry': {
    account: {
      token: '<user_token>',
    },
  },
};

Actions

The following action types are supported:

  • keyDown, keyUp - presses/releases given key.
  • pointerMove - focuses the element using arrow buttons.
  • pause - waits given amounts of milliseconds.

Below are the key codes and their equivalents in the roku remote.

CodeKeyboard KeyRoku Key
\uE002HelpInfo
\ue003BackspaceBackspace
\ue006ReturnEnter
\ue007EnterSelect
\ue00bPausePlay
\uE00CEscapeBack
\uE00EPage UpChannelUp
\uE00FPage DownChannelDown
\ue011HomeHome
\ue012Arrow LeftLeft
\ue013Arrow UpUp
\ue014Arrow RightRight
\ue015Arrow DownDown
\uE01A0InputAV1
\uE01B1InputHDMI1
\uE01C2InputHDMI2
\uE01D3InputHDMI3
\uE01E4InputHDMI4
\uE01F5InputTuner
\uE036F6InstantReplay
\uE037F7Rev
\uE038F8Play
\uE039F9Fwd
\uE03AF10VolumeMute
\uE03BF11VolumeDown
\uE03CF12VolumeUp

Capabilities

If adding a vendor prefix is a problem, @appium/relaxed-caps-plugin can be used to get rid of them.

Roku Capabilities

CapabilityRequiredTypeDescription
appium:ip+stringThe IP address of the target device
appium:password+stringPassword for the development environment
appium:username-stringUsername for the development environment
appium:context-stringSets the context to be used, default ECP
appium:registry-objectPre-fills the registry with the specified sections/keys
appium:arguments-objectParameters to be passed to the main method
appium:entryPoint-stringSpecifies the channel entry point, possible values are channel, screensaver, screensaver-settings

Appium Capabilities

CapabilityRequiredTypeDescription
platformName+stringMust be roku
appium:automationName+stringMust be roku
appium:deviceName+/-StringHelps webdriver clients understand that they are dealing with appium
appium:app-stringThe absolute local path or remote http URL to channel
appium:noReset-booleanDo not stop app, do not clear app data, and do not uninstall app
appium:printPageSourceOnFindFailure-booleanWhen a find operation fails, print the current page source. Defaults to false
appium:newCommandTimeout-numberHow long (in seconds) Appium will wait for a new command from the client before assuming the client quit and ending the session
appium:settings[<key>]-anyUpdate driver settings on session creation
appiun:shouldTerminateApp-booleanIf true, the channel will be closed after the session is finished. Defaults to false

Settings

NameTypeDescription
elementResponseAttributesstringComma-separated list of element attribute names that will be available in page source and related actions

Supported Commands

The supported commands are listed in the sections below but note that they may have a different name in the client you are using

Example: calling the setContext command

// Java
driver.context('ECP');

// WebdriverIO
driver.switchContext('ECP');

WebDriver Commands

CommandDescription
createSessionCreate a new session
deleteSessionEnd the running session
setUrlOpen a deep link
activeGet the currently focused element
findElementSearch for an element
findElementsSearch for multiple elements
findElementFromElementSearch for an element in parent element
findElementsFromElementSearch multiple elements in parent element
getAttributeGet the value of an attribute from a given element
getPropertyGet the value of an property from a given element isFocused - returns true if the element is focused.isInFocusChain - returns true if the element or any of its descendants are focusedisInFocusHierarchy - returns true if the element or any of its ancestors or descendants is focused
getTextGet the visible text of a given element
getNameGet the tag name of given element
getElementRectGet the position and size of the given element
elementDisplayedCheck if the element is displayed
clickPresses the Select button on given element
clearClears the content of the given element
setValueSend a sequence of keystrokes to an element
getPageSourceGet the XML representation of the current UI
executeExecute an roku command
performActionsPerforms a chain of actions
releaseActionsRelease depressed key
getScreenshotTake a screenshot

Appium Commands

CommandDescription
installAppInstall the channel if it is not installed
activateAppLaunch the given channel
removeAppRemove the given channel from the device
isAppInstalledChecks if a channel is installed
queryAppStateQueries the channel state
pushFilePush a file to the device
pullFilePull a file from the device
pullFolderPull a folder from the device
updateSettingsUpdates current test session settings
getCurrentContextGet the name of the current context
setContextSwitches to the given context
getContextsGet the names of available contexts

Roku Commands

In addition to the standard apium commands, Roku has several additional features that go beyond the appium protocol, so they are available through a javascript executor and a script in the following format <component>:<command>

The following components are available: ecp, debugServer, developerServer, and odc

Example:

// with args
driver.execute('ecp:launch', [{ appId: 'dev', params: {} }]);

// without args
const playerState = driver.execute('ecp:queryMediaPlayer');
playerState.duration;
0.11.3

6 days ago

0.11.2

1 month ago

0.11.1

3 months ago

0.11.0

3 months ago

0.10.1

4 months ago

0.10.0

5 months ago

0.8.5

6 months ago

0.8.4

8 months ago

0.9.0

6 months ago

0.9.1

6 months ago

0.8.3

2 years ago

0.8.1

2 years ago

0.8.2

2 years ago

0.8.0

2 years ago

0.7.1

3 years ago

0.7.0

3 years ago

0.5.0

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.1

3 years ago

0.6.0

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago