Using Cloud Services
Using on-demand services like Sauce Labs, Browserstack, TestingBot, CrossBrowserTesting or LambdaTest 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.
#
Sauce LabsIt is easy to 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 ConnectIf 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 CITravis 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
:
#
TimeoutsSince you are running your tests remotely, it might be necessary to increase some timeouts.
You can change the idle timeout by passing idle-timeout
as a test configuration option. This controls how long Sauce will wait between commands before closing the connection.
#
BrowserStackWebdriverIO also has a Browserstack integration built-in.
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 Browserstack automate username and access key.
You can also pass in any optional supported capabilities as a key/value in the capabilities for any browser. If you set browserstack.debug
to true
it will record a screencast of the session, which might be helpful.
#
Local TestingIf you want to run tests against a server that is not accessible to the Internet (like on localhost
), then you need to use Local Testing.
It is out of the scope of WebdriverIO to support this, so you must start it by yourself.
If you do use local, you should set browserstack.local
to true
in your capabilities.
If you are using the WDIO testrunner, download and configure the wdio-browserstack-service
in your wdio.conf.js
. It helps get BrowserStack running, and comes with additional features that better integrate your tests into the BrowserStack service.
#
With Travis CIIf you want to add Local Testing in Travis, you have to start it by yourself.
The following script will download and start it in the background. You should run this in Travis before starting the tests.
Also, you might wish set the build
to the Travis build number.
Example capabilities
:
#
TestingBotThe 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 TestingBot username and secret key.
You can also pass in any optional supported capabilities as a key/value in the capabilities for any browser.
#
Local TestingIf you want to run tests against a server that is not accessible to the Internet (like on localhost
), then you need to use Local Testing. TestingBot provides a Java-based tunnel to allow you to test websites not accessible from the internet.
Their tunnel support page contains the information necessary to get this up and running.
If you are using the WDIO testrunner, download and configure the @wdio/testingbot-service
in your wdio.conf.js
. It helps get TestingBot running, and comes with additional features that better integrate your tests into the TestingBot service.
#
CrossBrowserTestingThe 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 CrossBrowserTesting username and authkey.
You can also pass in any optional supported capabilities as a key/value in the capabilities for any browser.
#
Local TestingIf you want to run tests against a server that is not accessible to the Internet (like on localhost
), then you need to use Local Testing. CrossBrowserTesting provides a tunnel to allow you to test websites not accessible from the internet.
If you are using the WDIO testrunner, download and configure the @wdio/crossbrowsertesting-service
in your wdio.conf.js
. It helps get CrossBrowserTesting running and comes with additional features that better integrate your tests into the CrossBrowserTesting service.
#
LambdaTestLambdaTest integration is also built-in.
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 LambdaTest account username and access key.
You can also pass in any optional supported capabilities as a key/value in the capabilities for any browser. If you set visual
to true
it will record a screencast of the session, which might be helpful.
#
Tunnel for local testingIf you want to run tests against a server that is not accessible to the Internet (like on localhost
), then you need to use Local Testing.
It is out of the scope of WebdriverIO to support this, so you must start it by yourself.
If you do use local, you should set tunnel
to true
in your capabilities.
If you are using the WDIO testrunner, download and configure the wdio-lambdatest-service
in your wdio.conf.js
. It helps get LambdaTest running, and comes with additional features that better integrate your tests into the LambdaTest service.
#
With Travis CIIf you want to add Local Testing in Travis, you have to start it by yourself.
The following script will download and start it in the background. You should run this in Travis before starting the tests.
Also, you might wish set the build
to the Travis build number.
Example capabilities
: