End-to-end Roku tests using webdriver.io.
This is possible thanks to the amazing effort done by @dlenroc and the appium roku driver he created. Check out his github for an in-depth look at the driver.
- Install dependencies and set config
$ npm install -g appium@next $ yarn install $ appium driver install --source npm @dlenroc/appium-roku-driver
- Set device
appium:ip,appium;passwordintests/wdio.conf.ts, andappium:app. - Run tests
$ yarn wdio
To run specific tests, use the --spec option with the files you want to test:
$ yarn wdio --spec login.spec.tsThere are 2 contexts that are supported:
-
ECP(default) External Control Protocol is a context that finds elements quickly, but can report incorrect element coordinates and does not see many attributes. -
ODCOn Device Component is a context that sees all attributes and reports coordinates relative to the viewport (can be tuned using elementResponseAttributes setting). This has a lot more info but is much slower.
The roku webdriver supports several location strategies:
id, tag name, link text, partial link text, css selector and xpath .
A semi-efficient way to find these elements is by using the Appium Inspector. Once the tool is installed launch Appium:
$ appiumand configure the inspector with the required capes:
{
"platformName": "roku",
"appium:automationName": "roku",
"appium:deviceName": "<deviceName",
"appium:app": "<path-to.zip>",
"appium:ip": "<roku-ip>",
"appium:password": "<roku-dev-password>",
"appium:context": "ECP" // optional
}
More optional capes can be found in the roku driver repo.
Elements can also be found by looking directly at the app-ui endpoint in a browser.
ECP - 'roku-ip-address:8060/query/app-ui' or
ODC - 'roku-ip-address:8061/app-ui'
Once the element(s) is/are found they can be used with the Webdriver.io query commands: Some examples:
await $('*=driver')
await $$('//body/p[2]')
await $('#someid')