Skip to main content

Test Observability on WebdriverIO

Quick start guide to integrate BrowserStack Test Observability with WebdriverIO

Test Observability is currently in private-alpha. If you do not yet have access to the product, you can reach out to us requesting early access.

Pre-requisites

  • You have an account with BrowserStack (even free trial works) and cen get the username and access key from Settings.
  • You have a WebdriverIO test suite (its okay even if you do not run your tests on BrowserStack infrastructure)

Integrate with Test Observability

You can use BrowserStack Test Observability both when you’re using BrowserStack’s devices and browsers to run your tests and also if you’re running tests locally on your laptop/CI system or even when you’re using some other cloud provider.

Please select your setup below to get started with awesome debugging experience with Test Observability:

To start using BrowserStack Test Observability with your existing setup of WebdriverIO tests running on BrowserStack Automate or App Automate, follow the steps below:

Install the latest version of browserstack-service npm package

You’d most likely need to update the browserstack-service as shown below:

Terminal
npm install @wdio/browserstack-service@latest --save-dev

Make sure BrowserStack credentials are specified

Your wdio.conf.js should already contain the below mentioned key-value pairs:

wdio.conf.js
  exports.config = {
    ...
    user: 'YOUR_USERNAME' || process.env.BROWSERSTACK_USERNAME,
    key: 'YOUR_ACCESS_KEY' || process.env.BROWSERSTACK_ACCESS_KEY,
    ...
  };

Specify static buildName and projectName in your config

BrowserStack Test Observability organizes your build runs (a.k.a job runs) into projects and builds. You need to specify a projectName and buildName under the config shown below and they must be static and not change across different runs. We will identify a run and increment the run number automatically.

The projectName and buildName config must be static and not change across different runs of the same build. This is a deviation in approach as specified by BrowserStack Automate or App Automate since Test Observability will automatically identify different build runs.

wdio.conf.js
  exports.config = {
    ...
    capabilities: [{
        ...
        'bstack:options': {
          'projectName': 'Your static Test Observability Project name goes here',
          'buildName': 'Your static build name goes here',
          'buildTag': 'Any build tag goes here'
      }
    }],
  };

Make sure browserstack service is added in your WDIO config

Cross-check that the browserstack service exists in your webdriverIO config file:

wdio.conf.js
  exports.config = {
    ...
    services: [
      ['browserstack']
    ]
  };

Any other config parameters that are already existing, can exist as it is.

If you do not see your data on Test Observability dashboard after following the steps above, please reach out to us.

Run your suite with BrowserStack Test Observability

Use your existing command that you use to trigger a run and data will automatically start getting sent to BrowserStack Test Observability.

Post build run completion, you will see the build URL of Test Observability. Alternatively, you can also navigate to your build run through the Test Observability dashboard.

Visit Test Observability Dashboard

To integrate your WebdriverIO tests with BrowserStack Test Observability, follow the steps below:

Get the latest version of browserstack-service npm package

You can use BrowserStack Test Observability even if your tests are running locally or on any other cloud service provider. All you’d need to do is add the browserstack-service dependency to your project’s package.json as shown below:

Terminal
npm install @wdio/browserstack-service@latest --save-dev

Set up your BrowserStack credentials in environment variables

Your BrowserStack account credentials need to be specified as environment variables as shown below. You can find your account credentials in Account settings. Even free trial account on BrowserStack is good enough to use Test Observability for now.

# Set these values in your ~/.zprofile (zsh) or ~/.profile (bash)
  export BROWSERSTACK_USERNAME="YOUR_USERNAME"
  export BROWSERSTACK_ACCESS_KEY="YOUR_ACCESS_KEY"
# setx.exe does not set the environment variable in the current command prompt, but it will be available in subsequent command prompts
  setx BROWSERSTACK_USERNAME="YOUR_USERNAME"
  setx BROWSERSTACK_ACCESS_KEY="YOUR_ACCESS_KEY"

# Verify whether the variables have been set
echo BROWSERSTACK_USERNAME
echo BROWSERSTACK_ACCESS_KEY

Add buildName and projectName in your capabilities

BrowserStack Test Observability organizes your build runs (a.k.a job runs) into projects and builds. You need to specify a projectName and buildName under the config shown below. Both of them should be static and should not change over different runs. We will identify a run and increment the run number automatically.

wdio.conf.js
  exports.config = {
    ...
    capabilities: [{
        ...
        'bstack:options': {
          'projectName': 'Test Observability Project name goes here',
          'buildName': 'Your static build name goes here',
          'buildTag': 'Any build tag goes here'
      }
    }],
  };

Set up the webdriverIO config for Test Observability

Add the browserstack service in your webdriverIO config file:

wdio.conf.js
  exports.config = {
    ...
    services: [
      ['browserstack']
    ]
  };

Run your suite with BrowserStack Test Observability

Use your existing command that you use to trigger a run and data will automatically start getting sent to BrowserStack Test Observability.

Post build run completion, you will see the build URL of Test Observability. Alternatively, you can also navigate to your build run through the Test Observability dashboard.

Visit Test Observability Dashboard

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback!

Talk to an Expert
Download Copy