Roku Robot Framework Library
Roku's Robot Framework Library enables keyword-driven testing of apps. The library resides in a Python class that has methods that map directly to keyword names. The keywords take the same arguments as the methods implementing them. The keywords report failures with exceptions, create logs by writing to standard output, and return values using the return statement.
Instantiating the library
To create an instance of the Roku Framework Robot Library, provide the following four arguments:
The following example demonstrates how to instantiate the Roku Robot Framework Library:
*** Settings ***
Library ./../Library/RobotLibrary.py ${ip_address} ${timeout} ${pressDelay} ${server_path}
*** Variables ***
${ip_address} 127.0.0.1
${server_path} D:/path/to/webDriver/main.exe
${timeout} 20000
${pressDelay} 2000
.py file:
class RobotLibrary:
def __init__(self, ip, timeout = 0, pressDelay = 0, path = ""):
<some code>
Keywords
The Roku's Robot Framework Library includes the following keywords:
- Sideload (available since release 2.0)
- Launch the app
- Input deep linking data (available since release 2.0)
- Get apps
- Send key
- Send keys
- Send word
- Mark timer
- Get timer
- Verify is playback started (available since release 2.0)
- Verify is screen loaded (available since release 2.0)
- Get child nodes (available since release 2.1)
- Get element
- Get elements
- Get focused element
- Verify is app loaded
- Get current app info
- Get device info
- Get player info
- Verify app exists
- Set timeout
- Set press delay
- Get attribute
A keyword will fail if its respective WebDriver endpoint returns a 4xx or 500 error.
Sideload
(available since release 2.0)
Launch the app
(available since release 2.0)
Get apps
Send key
Send keys
Send word
Mark timer
(available since release 2.0)
Get timer
(available since release 2.0)
Verify is playback started
Verify is screen loaded
Get child nodes
-
locator: An array containing search criteria for the child nodes to be retrieved. The locator has the following syntax:
using=attribute, tag, or text attribute=specific attribute value=tag or attribute value
Get element
Get elements
Get focused element
Verify is channel loaded
Get current channel info
Get device info
Get player info
Verify is channel exist
Set timeout
Set press delay
Get attribute
Sample test cases
The Roku automated app testing repository includes a set of sample Robot Framework test cases that can be executed on their corresponding SceneGraph Developer Extensions (SGDEX) sample apps. For example, you can execute the SGDEX GridView test case (test_3_Grid.robot), which will sideload the corresponding sample app (3_Grid) on your device, and then view the test output. You can reference these samples when developing test scripts for the automated testing of your development apps.
Before running a sample test case, you need to update the sideload command in the test case with the Roku device password.
The Basic_tests.robot sample demonstrates how to create a simple test case that checks whether a user is authenticated before playing content using the Roku Robot Framework Library:
*** Settings ***
Documentation Basic smoke tests
Variables ./../Library/variables.py
Library ./../Library/RobotLibrary.py ${ip_address} ${timeout} ${pressDelay} ${server_path}
Library Collections
*** Variables ***
${channel_code} dev
&{DATA2}= using=text value=Barack Gates, Bill Obama
@{DATA2Array}= &{DATA2}
&{Params2}= elementData=${DATA2Array}
&{DATA3}= using=text value=Please enter your username
@{DATA3Array}= &{DATA3}
&{Params3}= elementData=${DATA3Array}
&{DATA4}= using=text value=Please enter your password
@{DATA4Array}= &{DATA4}
&{Params4}= elementData=${DATA4Array}
@{KEYS}= down down down down select
&{DATA5}= using=text value=Authenticate to watch
@{DATA5Array}= &{DATA5}
&{Params5}= elementData=${DATA5Array}
*** Test Cases ***
Channel should be launched
Side load ../sample/channel.zip rokudev aaaa
Verify is channel loaded ${channel_code}
Check if details screen showed
Send key select 4
Verify is screen loaded ${Params2}
Check if playback started
${status} ${value}= Run Keyword And Ignore Error Verify is screen loaded ${Params5} 2
Run keyword if "${status}"=="PASS" Do auth
... ELSE Send key select
Verify is playback started 20 2
*** Keywords ***
Do auth
Send key select
Verify is screen loaded ${Params3}
Send word user
Send keys ${KEYS}
Verify is screen loaded ${Params4}
Send word pass
Send keys ${KEYS}
Viewing the test case report and log
After you run a test case that uses the Roku Robot Framework Library, you can view the generated report and log files in the specified output directory. The report summarizes the test case and provides statistics on the percentage of individual tests that passed/failed. The log details the success/failure of the individual keywords used in each test case.
