WebdriverIO & Selenium Test Harness
Why
This test harness allows you to setup bootstrap your feature/intergration tests with WebdriverIO and Selenium. It makes setup and teardown trivial, especially for starting and stopping a local selenium server.
Installation
First you want to install the peerDependencies
and then the package itself.
npm i -D webdriverionpm i -D selenium-standalonenpm i -D webdriverio-selenium-harness
Usage
You can use the test harness in your test framework of choice.
Just require the module and call setup
and teardown
in your before
and after
hooks.
Example
// Mocha var harness = var options = {}
Caveats
- Make sure you have your Browsers or PhantomJS installed.
- Install Selenium by running
./node_modules/.bin/selenium-standalone install
.
Reference: https://www.npmjs.com/package/selenium-standalone - Make sure if your tests ever crash that,
teardown
always run. Otherwise you may have processes left on.
API
Setup
setup
takes an object of options for both webdriverio and selenium.
setup
returns a Promise of harness state which contains the webdriverio client and the selenium process.
Options are namespaced by webdriverio and selenium.
Each of the options will reflect the APIs provided in these documents.
References
WebdriverIO
Selenium
Custom
- remoteSelenium
Use if you want to the test harness to point to a remote selenium server.
Examples
Traditional
An example of how to use on your local.
var options = custom: {} selenium: seleniumArgs: webdriverio: init: {} remote: desiredCapabilities: browserName: 'phantomjs' // chrome, firefox harness
Continuous Integration
An example of how to use in CI.
Note
The Selenium instance in the harness state is a stub process when using remoteSelenium
.
Make sure you have a Selenium server running when using remoteSelenium
custom option.
var isCI = !!processenvCI var options = custom: remoteSelenium: isCI selenium: seleniumArgs: webdriverio: init: {} remote: desiredCapabilities: browserName: 'phantomjs' // chrome, firefox harness
Teardown
teardown
takes harness state and then closes the webdriverio client and selenium process.
teardown
will return a Promise of undefined.
Example
harness