webdriver-runner
driverconst exploreLink = driver3exploreLinkdriver
Simple test runner for Synchronized selenium webdriver tests built on mochajs and selenium-webdriver. this project is heaviley inspired from WebdriverIO & Selenium-Webdriver
Basic examples are at lib/examples
Install
npm install webdriver-runner
Note: selenium-webdriver
will not be installed as it is not a direct dependency. Client is free to install any version of selenium-webdriver.
Getting started
We are excited that you want to try webdriver-runner.
webdriver-runner is a simple test runner for webdriver tests. The main features it provides are
- Making webdriver synchronous.
- Running tests parellel.
- Reporting capabilities.
it provides Launcher
API to trigger tests. it takes a configuration object with test-files, mocha-options, browser capabilities and others to run. As of now, this library only provides programmable launcher.
Simple code snippet to start tests:
# file: test/runnerjsconst Launcher = Launcherconst request =specs:tests: 'test/*.test.js'browsers:request
Then
node test/runner.js
will start the tests.
Build webdriver instance
To keep this library simple, it delegates the task of building webdriver instance to test scripts, however it provides a thin wrapper to make the driver instance synchronous. So test script will have
# file: home-pagetestjsconst drivertest
Few important things here are:
webdriver-runner/synchronize
hasdriver
method which makes the origin webdriver instance as synchronous.webdriver-test/testing
has extended test hooks to provide the context on which synchronous driver calls will execute.- Calling synchronous methods outside test-hooks will throw Errors.
Get browser config
webdriver-runner's Launcher will pass the browser-config to test scripts through global scope. it is test scripts responsibility to create an instance for given requirement.
For example:
global.browserConfig
will hold the browser object set to Launcher request.
const browser = globalbrowserConfigconst builder =if browsername === 'chrome'builderelsebuilderconst driverPromise = builder
Test configuration API
Lets look at the fields of test request
const request =// mocha options; see below links for all optionsmochaOptions:retries: 1requires: 'babel-core/register'timeout: 900000// pass extra flags to test scripts.execArgv:'--env=dev'reporters: SpecSummaryreporterOptions: {}specs:tests: 'tests/*.test.js'// each of this browser instance will be available to test-suite at runtime in global scope (`global.browserConfig`)// so, suite can build a new brower instancebrowsers:name: 'chrome'shard: 3
Reference links:
Examples
Basic example of webdriver-runner is maintained in lib/examples
directory. To run examples
$cd examples
npm install && npm test
Issues
please log your issues on github