Using Cloud Services
Using on-demand services like Sauce Labs, Browserstack, TestingBot, LambdaTest or Perfecto with WebdriverIO is pretty simple. All you need to do is to set your service's user
and key
in your options.
Optionally, you can also parametrize your test by setting cloud-specific capabilities like build
. If you only want to run cloud services in Travis, you can use the CI
environment variable to check if you are in Travis and modify the config accordingly.
// wdio.conf.js
export let config = {...}
if (process.env.CI) {
config.user = process.env.SAUCE_USERNAME
config.key = process.env.SAUCE_ACCESS_KEY
}
Sauce Labs
You can set up your tests to run remotely in Sauce Labs.
The only requirement is to set the user
and key
in your config (either exported by wdio.conf.js
or passed into webdriverio.remote(...)
) to your Sauce Labs username and access key.
You can also pass in any optional test configuration option as a key/value in the capabilities for any browser.
Sauce Connect
If you want to run tests against a server that is not accessible to the Internet (like on localhost
), then you need to use Sauce Connect.
It is out of the scope of WebdriverIO to support this, so you'll have to start it by yourself.
If you are using the WDIO testrunner download and configure the @wdio/sauce-service
in your wdio.conf.js
. It helps getting Sauce Connect running and comes with additional features that better integrate your tests into the Sauce service.
With Travis CI
Travis CI, however, does have support for starting Sauce Connect before each test, so following their directions for that is an option.
If you do so, you must set the tunnel-identifier
test configuration option in each browser's capabilities
. Travis sets this to the TRAVIS_JOB_NUMBER
environmental variable by default.
Also, if you want to have Sauce Labs group your tests by build number, you can set the build
to TRAVIS_BUILD_NUMBER
.
Lastly, if you set name
, this changes the name of this test in Sauce Labs for this build. If you are using the WDIO testrunner combined with the @wdio/sauce-service
, WebdriverIO automatically sets a proper name for the test.
Example capabilities
:
browserName: 'chrome',
version: '27.0',
platform: 'XP',
'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER,
name: 'integration',
build: process.env.TRAVIS_BUILD_NUMBER