Configuration

If you create a WebdriverIO instance you need to define couple of options in order to set the proper capabilities and settings. When calling the remote method like:

1
2
var webdriverio = require('webdriverio');
var client = webdriverio.remote(options);

you need to pass in an object that should contain the following properties:

desiredCapabilities

Defines the capabilities you want to run in your Selenium session. See the Selenium documentation for a list of the available capabilities. Also useful is Sauce Labs Automated Test Configurator that helps you to create this object by clicking together your desired capabilities.

Refer to the cloud service docs for further service specific options.

Type: Object
Default: { browserName: 'firefox' }

Example:

1
2
3
4
5
browserName: 'chrome',  // options: firefox, chrome, opera, safari
version: '27.0', // browser version
platform: 'XP', // OS platform
tags: ['tag1','tag2'], // specify some tags (e.g. if you use Sauce Labs)
name: 'my test' // set name for test (e.g. if you use Sauce Labs)

logLevel

Level of logging verbosity.

Type: String
Default: silent
Options: verbose | silent | command | data | result

logOutput

Pipe WebdriverIO logs into a file. You can define either a directory and WebdriverIO generates a filename for the log file or you can pass in writeable stream and everything gets redirected to that (last one doesn’t work yet with the wdio runner).

Type: String|writeable stream
Default: null

host

Host of your WebDriver server.

Type: String
Default: 127.0.0.1

port

Port your WebDriver server is on.

Type: Number
Default: 4444

path

Path to WebDriver server.

Type: String
Default: /wd/hub

baseUrl

Shorten url command calls by setting a base url. If your url parameter starts with / the base url gets prepended.

Type: String
Default: null

coloredLogs

Enables colors for log output

Type: Boolean
Default: true

screenshotPath

Saves a screenshot to a given path if Selenium driver crashes

Type: String|null
Default: null

waitforTimeout

Default timeout for all waitForXXX commands.

Type: Number
Default: 500

waitforInterval

Default interval between checks in waitForXXX commands.

Type: Number
Default: 250

Setup Babel to write tests using next generation JavaScript

There are multiple ways to setup Babel using the wdio testrunner. If you are running Cucumber or Jasmine test you just need to register Babel in the before hook of your config file

1
2
3
4
5
6
7
before(function() {
require('babel/register')({
blacklist: [
'regenerator'
]
});
}),

Make sure to allow generator calls to directly go through since Node >v0.10 has sufficient generator support.

If you run Mocha test you can use Mochas internal compiler to register Babel, e.g.:

1
2
3
4
5
mochaOpts: {
ui: 'bdd',
compilers: ['js:babel-core/register'],
require: ['./test/helpers/common.js']
},

For generator support, add a file called .babelrc to your project root directory with the following content:

1
2
3
{
"blacklist": ["regenerator"]
}