Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Environment:Webdriverio Webdriverio Cloud Service Credentials

From Leeroopedia
Knowledge Sources
Domains Infrastructure, Cloud_Testing
Last Updated 2026-02-12 01:00 GMT

Overview

Environment variables and credentials required for BrowserStack, Sauce Labs, and TestingBot cloud testing integrations in WebdriverIO.

Description

WebdriverIO supports multiple cloud testing providers through dedicated service packages. Each provider requires specific environment variables for authentication and configuration. These credentials are read from `process.env` at runtime and can also be set in the WDIO configuration file. The BrowserStack service has the most extensive set of environment variables, including those for test observability, accessibility testing, and AI-powered self-healing features.

Usage

Use this environment when running WebdriverIO tests against cloud browsers via BrowserStack, Sauce Labs, or TestingBot. This is the mandatory prerequisite for the Cloud_Capabilities_Config, BrowserStack_Launcher_Tunnel, and Cloud_Service_Hooks implementations.

System Requirements

Category Requirement Notes
Network Internet access Must reach cloud provider API endpoints
Node.js >= 18.20.0 Same as base WebdriverIO requirement

Dependencies

Language Packages

BrowserStack:

  • `@wdio/browserstack-service` = 9.24.0
  • `browserstack-local` ^1.5.1 (for local tunnel)

Sauce Labs:

  • `@wdio/sauce-service` = 9.24.0
  • `saucelabs` ^9.0.1

TestingBot:

  • `@wdio/testingbot-service` = 9.24.0
  • `testingbot-tunnel-launcher` ^1.1.7

Credentials

NEVER store actual credential values in code or configuration files committed to version control.

BrowserStack (Required)

  • `BROWSERSTACK_USERNAME`: BrowserStack account username for authentication.
  • `BROWSERSTACK_ACCESS_KEY`: BrowserStack account access key for authentication.

BrowserStack (Optional)

  • `BROWSERSTACK_BUILD_NAME`: Custom build name for test grouping.
  • `BROWSERSTACK_TESTHUB_JWT`: JWT token for TestHub session integration.
  • `BROWSERSTACK_TESTHUB_UUID`: Build hashed ID for TestHub.
  • `BROWSERSTACK_ACCESSIBILITY`: Enable accessibility testing session (`true`/`false`).
  • `BROWSERSTACK_OBSERVABILITY`: Enable test observability and reporting (`true`/`false`).
  • `BS_TESTOPS_ALLOW_SCREENSHOTS`: Allow screenshot capture in test observability.
  • `BROWSERSTACK_RERUN`: Comma-separated list of tests to rerun.
  • `BROWSERSTACK_RERUN_TESTS`: Whether current run is a rerun (`true`/`false`).

Sauce Labs

  • `SAUCE_USERNAME`: Sauce Labs account username.
  • `SAUCE_ACCESS_KEY`: Sauce Labs access key.

TestingBot

  • `TESTINGBOT_KEY`: TestingBot API key.
  • `TESTINGBOT_SECRET`: TestingBot API secret.

Quick Install

# BrowserStack
npm install @wdio/browserstack-service
export BROWSERSTACK_USERNAME="your_username"
export BROWSERSTACK_ACCESS_KEY="your_access_key"

# Sauce Labs
npm install @wdio/sauce-service
export SAUCE_USERNAME="your_username"
export SAUCE_ACCESS_KEY="your_access_key"

# TestingBot
npm install @wdio/testingbot-service
export TESTINGBOT_KEY="your_key"
export TESTINGBOT_SECRET="your_secret"

Code Evidence

BrowserStack constants from `packages/wdio-browserstack-service/src/constants.ts:32-50`:

export const DATA_ENDPOINT = 'https://collector-observability.browserstack.com'
export const APP_ALLY_ENDPOINT = 'https://app-accessibility.browserstack.com/automate'
export const DATA_BATCH_SIZE = 1000
export const DATA_BATCH_INTERVAL = 2000
export const DEFAULT_WAIT_TIMEOUT_FOR_PENDING_UPLOADS = 5000
export const DEFAULT_WAIT_INTERVAL_FOR_PENDING_UPLOADS = 100

BrowserStack credential reading from `packages/wdio-browserstack-service/src/util.ts`:

const username = config.user || process.env.BROWSERSTACK_USERNAME
const accessKey = config.key || process.env.BROWSERSTACK_ACCESS_KEY

Sauce Labs credential reading from CI workflow `.github/workflows/test-cloud.yml`:

env:
  SAUCE_USERNAME: ${{secrets.SAUCE_USERNAME}}
  SAUCE_ACCESS_KEY: ${{secrets.SAUCE_ACCESS_KEY}}

Common Errors

Error Message Cause Solution
`401 Unauthorized` Missing or invalid credentials Verify `BROWSERSTACK_USERNAME`/`SAUCE_USERNAME` and access key are set
`Could not start local testing` BrowserStack Local tunnel failed Set `forcedStop: true` in service options as workaround for tunnel hang
`Proxy authentication required` Corporate proxy blocks cloud access Set `PROXY_URL` environment variable for HTTP/HTTPS proxy

Compatibility Notes

  • BrowserStack Local: The `forcedStop` option kills the tunnel process immediately on test completion. This is a workaround for a known issue where the stop callback hangs (browserstack-local-nodejs#41).
  • Sauce Labs: Supports both W3C and legacy JSONWire capabilities.
  • TestingBot: Supports local tunnel via `testingbot-tunnel-launcher`.
  • CI/CD: All credentials should be stored as CI secrets, never in repository files.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment