Skip to main content
No Result Found
Connect & Get help from fellow developers on our Discord community. Ask the CommunityAsk the Community

Load testing with WebdriverIO

Run a load test using WebdriverIO scripts on BrowserStack Load Testing

Prerequisites

  • BrowserStack Username and Access key. You can find this under your account profile.
  • An automated test suite written in WebdriverIO

Use our load testing sample project to quickly get started.

Run a test

Based on your preferred method of performing load tests, use one of the following methods:

You can start a new test either from the Quick Start page, or the Load Tests page on the Load testing dashboard.

On the dashboard, click Create Load Test.

Screenshot of load testing dashboard showing the run a new test button highlighted

Enter a Test Name for your load test, select Browser Only and click Upload scripts

Dashboard showing test name field and type of load test to run

Upload scripts

In this step, upload your WebdriverIO automation project as a ZIP file. Select your framework (for example, WebdriverIO) from the dropdown, then drag and drop your ZIP file (up to 250MB) or click to select it.

Screenshot of load testing dashboard asking to add scripts for load testing

After you upload your ZIP file, the dashboard automatically validates your project. If validation is successful, you will see a confirmation message and a summary of the detected configuration and dependencies.

You can review and confirm the configuration file (your webdriverio config file) and any other dependencies (path of package.json) identified in your project.

Dashboard showing successful validation of a WebdriverIO project ZIP with config and dependencies

Ensure that your package.json and wdio.config.js config files are placed at the root level of your project.

Once you have verified the configuration, click Configure Load to move to the next step.

You can also run load tests using the sample scripts if you want to try out the feature before uploading your own files.

Configure environment variables

Use environment variables to avoid hard-coding secrets and to parameterize your test runs:

  • Upload one or more .env files (up to 5 MB each) by dragging and dropping into the upload area:
    • You can upload .env, .yaml, .yml, .json, .properties, .ini, or .cfg files.
    • After upload, the variables become available to your test run.
  • Manually add key–value pairs:
    • Click Add Variable, then enter the Key and Value.
    • Your variables are saved for this run and applied during execution.
    • Use the bin icon to delete any key-value pair

Screenshot of load testing dashboard asking to upload env variable files and add values

Test data configuration

Use test data to inject external values so each virtual user (VU) runs with different inputs. This helps you simulate real-world traffic without hard-coding values into your scripts.

  • Expand Test Data and upload a .csv. You can upload up to three files per test, each not exceeding 10 MB and 100 columns. Ensure the .csv files have headers. The system automatically stores up to five versions of each file.

Screenshot of load testing dashboard showing test data section expanded

  • After upload: set delimiter; confirm header row and row count; headers map to variables.

Screenshot of load testing dashboard showing delimiter after file upload

  • Choose how VUs pick rows from the data file. Random (per-iteration random, high-volume) or Sequential (circular, even distribution).

Screenshot of load testing dashboard showing vu data mapping

Add the filepath, delimiter and vuMappingStrategy values to the testData block. Ensure that the filepath value should use relative paths instead of absolute paths. You can add up to three files under the testData block.

Code implementation example

For this feature to work, ensure that your code reads only the first row from the uploaded CSV file. Refer to the sample JavaScript snippet below:

const row = await readFirstRow('test-data-extra.csv');

export async function readFirstRow(csvFilePath) {
  return new Promise((resolve, reject) => {
    let firstRow = null;
    const fullPath = path.resolve(csvFilePath);
    
    const stream = fs.createReadStream(fullPath)
      .pipe(csv())
      .on('data', (data) => {
        if (!firstRow) {
          firstRow = data;
          stream.destroy(); // Stop reading after first row
        }
      })
      .on('end', () => {
        console.log(`Read first row from ${csvFilePath}`);
        resolve(firstRow);
      })
      .on('close', () => {
        if (firstRow) {
          console.log(`Read first row from ${csvFilePath}`);
          resolve(firstRow);
        }
      })
      .on('error', (error) => {
        console.error(`Error reading CSV file: ${error.message}`);
        reject(error);
      });
  });
}

Configure load parameters

Use any of the following Load Profiles for your load test

Select Constant VUs from the dropdowm menu, and set the number of virtual users, test duration, and select load zones.

Screenshot of various load testing configurations available on the dashboard

  • Virtual Users: Enter the total number of users to simulate during the test.
  • Duration: Specify how long the test should run (in minutes).

Select Ramping VUs from the dropdown menu, and configure Ramp-up, Hold, and/or Ramp-down stages.

Screenshot of various stages of load testing configurations available on the dashboard

Each stage will have 4 parameters which will determine the shape of the load curve:

  • Type: Select Ramp-up, Hold, or Ramp-down
  • Duration: Specify the duration of the stage
  • Start VUs: Specify the number of VUs at the start of the stage
  • Target VUs: Specify the number of VUs at the end of the stage
    You can add additional stages as per your test requirement.

Select Per VU Iterations from the dropdowm menu, and set the number of virtual users, iterations, and the maximum test duration.

Screenshot of various load testing configurations available on the dashboard

  • Virtual users: Enter the total number of users to simulate during the test.
  • Iterations per VU: Specify the times each virtual user runs the script.
  • Max duration: Specify the upper bound on the test runtime (in minutes).
  • Select load zones: Choose the regions where your tests will run. For each load zone, set the percentage of total load to be distributed. The dashboard visualizes the split with a chart for easy reference.

Screenshot of various load zones available on the dashboard

Capture response details

Use the Capture response details toggle to record full request–response data for failing HTTP calls during the test. The toggle is set to ‘disabled’ by default.

Toggle enabled for Capture response details setting in BrowserStack load testing UI

Set thresholds

Use thresholds to decide test status based on performance and reliability metrics:

  • Click Thresholds to expand the section. Thresholds section expanded in BrowserStack load testing UI
  • Click Add metric for criteria and choose a metric. Add metric for criteria button with metric selection dropdown in BrowserStack load testing UI
  • Set the condition (for example, is greater than, is less than) and enter a value.
  • Repeat for additional metrics as needed:

Available metrics:

  • Total requests (count)
  • Error % (percentage)
  • Error count (count)
  • Avg request rate (req/s)
  • Avg response time (ms)
  • p90 response time (ms)
  • p75 LCP (s)
  • p75 INP (ms)
  • p75 FCP (s)
  • p75 TTFB (ms)
  • p75 CLS

After configuring all parameters, click Run Test to start your load test.

Configure multiple scenarios

The Multiple Scenarios feature in the Load Configuration section allows you to simulate diverse user behaviors by executing different test flows simultaneously within a single load test. Instead of running a uniform workload, you can define specific user journeys to run in parallel, creating a more realistic traffic simulation.

All scenarios execute concurrently during the test run. You can configure up to 10 distinct scenarios per test.

Steps to configure multiple scenarios

Enable multiple scenarios

In the Load Configuration section, enable the Multiple Scenarios toggle.

Screenshot of multiple scenarios configuration in BrowserStack WebDriverIO load testing UI

Add a new scenario

Click Add Scenario to create a new scenario.

Configure scenario details

For each scenario:

  • Provide a unique name for easy identification.
  • Select the desired test cases using the supported selector types.
  • Provide load configuration details like number of VUs, load profile and regions.

Screenshot of scenario configuration in BrowserStack WebDriverIO load testing UI

For WebDriverIO tests, the following selector types are supported:

Selector type Description
Config file WebDriverIO configuration file path

Add additional scenarios

Repeat the process to add more scenarios as needed, up to the maximum limit of 10 scenarios per test.

Review the configuration

Review the configuration to ensure all scenarios are set up correctly.

Network throttling

Network throttling enables you to run load tests under real-world network conditions. This helps you understand how your application behaves for users on different connection types.

Simulate common networks or define a custom network profile. Network throttling applies to all virtual users in the test.

Supported modes

The following two modes are supported for configuring network throttling:

Use the following steps to apply predefined network throttling profiles:

  1. On your Load Testing dashboard, scroll to the Throttle Network section.
  2. Choose among the predefined profiles for 3G, Slow 4G, and Fast 4G.

Load testing dashboard showing the Throttle Network section with predefined network profile options for 3G, Slow 4G, and Fast 4G

Follow these steps to set up custom network throttling:

  1. On your Load Testing dashboard, scroll to the Throttle Network section and select Custom Values.
  2. Input your desired values for Latency, Upload, Download, and Packet Loss.

Load testing dashboard showing the Throttle Network section with custom network configuration fields for Latency, Upload, Download, and Packet Loss

Configuration parameters

The following table lists the available configuration parameters:

Parameter Type Description Unit Allowed Range
Latency number Simulated network latency ms 0 – 1,000,000
Download number Simulated download bandwidth kb/s 1 – 10,000,000
Upload number Simulated upload bandwidth kb/s 1 – 10,000,000
Packet Loss number Simulated packet loss percentage % 0 – 99

Set BrowserStack credentials

Save your BrowserStack credentials as environment variables. It simplifies running your test suite from your local or CI environment.

Copy icon Copy
Copy icon Copy
Copy icon Copy

Download BrowserStack NodeJS SDK

Run the given command to install the BrowserStack NodeJS SDK in your project

Copy icon Copy

Initialize your project for Load Testing

Run the given command from the root directory of your test project to generate the browserstack-load.yml file which contains the configuration required to define and run your load test:

Copy icon Copy

Configure your Load Test

Open the generated browserstack-load.yml file and update it with the relevant test details. Here’s a sample configuration:

Specify the test type

testType defines the type of load test that you want to execute. Currently, Playwright, Selenium and WebdriverIO are supported. Set this to WebdriverIO for a load test using WebdriverIO test suite.

Specify the path

The files block specifies the key files required to install dependencies and define which tests should be executed.

  • Under dependencies, add the path to files required to set up the environment. For Node.js projects, include the path to your package.json.
  • Under testConfigs, add the path to your wdio.conf.jsconfiguration file.

Specify number of virtual users

Set vus to the maximum number of virtual users to simulate during the test. The max limit for this config is currently 100. Contact us if you want to increase this limit.

Before running a full-scale load test, do a sanity check with a small set of virtual users to validate your configuration and test stability.

Set Regions

  • Use the loadzone sub-config to specify each region. For each region, set the traffic percentage using the percent sub-config.
  • Make sure that the total percentage equals 100.
Continent Region loadzone config value to be passed
North America US East (Virginia) us-east-1
North America US West (North California) us-west-1
Asia Asia Pacific (Mumbai) ap-south-1
Europe EU West (London) eu-west-2
Europe EU Central (Frankfurt) eu-central-1

Set duration

Each virtual user (VU) repeatedly executes the test(s) in a loop until the specified duration ends.

How to set duration values:

  • If less than 1 minute: use seconds (_s), e.g., 45s
  • If less than 1 hour: use minutes and seconds (_m_s), e.g., 12m30s , 10m
  • If 1 hour or more: use hours, minutes, and seconds (_h_m_s), e.g., 1h5m20s, 1h17m, 1h

Default value: By default, the duration is set to the time required to complete a single iteration of your test(s).
The maximum limit is 20 minutes, which you can extend on request.

You can set a constant duration or configure ramping VUs to model various load scenarios.

Configure Ramping VUs

If you want to gradually increase or decrease VUs over time, use the loadprofile config instead of duration. This approach lets you model realistic traffic patterns such as ramp-ups, peak holds, and ramp-downs.

  • Under the loadProfile block, set type to ramping to enable staged traffic changes.
  • Under stages, add one or more steps:
    • type: ramp increases or decreases VUs from from to to over duration. Result: VUs change linearly until they reach the target.
    • type: hold keeps VUs constant for duration. Result: VUs stay at the specified level without change.
  • Keep stage durations realistic. Very short ramps can cause bursty load that is hard to analyze.
  • Ensure your total vus is high enough to cover the largest stage to value. If not, the test cannot reach the target VUs.

Validation rules:

  • Each stage must include type, from, to, and duration.
  • Use valid time units (Xs, Xm, Xh). Example: 45s, 10m, 1h5m.
  • from and to must be non-negative integers and must not exceed the global vus limit.
  • Avoid overlapping or contradictory stages (for example, alternating rapid up/down ramps) unless you are testing resilience to bursty traffic.

Set iterations

Use iterations to control how many times each virtual user (VU) executes your test script:

  • Set iterations: positive integer per VU.
  • Combine with duration if needed: when both are set, the test stops when either the max duration or the per‑VU iterations are reached, whichever comes first.

Prefer loadprofile for ramping scenarios: avoid mixing iterations with staged ramping because it can create ambiguous end conditions.

Headless mode

You can configure your WebdriverIO load tests to run in either headless or headful mode using the headless capability.

  • Headless mode (default): The browser runs without a visible UI, which is faster and consumes fewer resources. Most CI/CD and automated load tests use headless mode.
  • Headful mode: The browser UI remains visible during test execution.

If not specified, tests will run in headless mode by default.

Set environment variables

The env config lets you pass an array of name-value string pairs to set environment variables on the remote machines where tests are executed.
Currently, a maximum of 20 pairs is allowed.

Environment variables can be set using any one of the following two methods:

Inline variables

Declare each variable with a name and value. BrowserStack injects these pairs into the test environment.

File-based variables:

Use sources to reference one or more files containing environment variables (for example, .env files). Use variables to add or override specific pairs. Result: the system loads values from files first, then applies overrides.

Test data configuration

Use test data to inject external values so each virtual user (VU) runs with different inputs. This helps you simulate real-world traffic without hard-coding values into your scripts.

Add the filepath, delimiter and vuMappingStrategy values to the testData block. Ensure that the filepath value should use relative paths instead of absolute paths. You can add up to three files under the testData block.

Code implementation example

For this feature to work, ensure that your code reads only the first row from the uploaded CSV file. Refer to the sample JavaScript snippet below:

const row = await readFirstRow('test-data-extra.csv');

export async function readFirstRow(csvFilePath) {
  return new Promise((resolve, reject) => {
    let firstRow = null;
    const fullPath = path.resolve(csvFilePath);
    
    const stream = fs.createReadStream(fullPath)
      .pipe(csv())
      .on('data', (data) => {
        if (!firstRow) {
          firstRow = data;
          stream.destroy(); // Stop reading after first row
        }
      })
      .on('end', () => {
        console.log(`Read first row from ${csvFilePath}`);
        resolve(firstRow);
      })
      .on('close', () => {
        if (firstRow) {
          console.log(`Read first row from ${csvFilePath}`);
          resolve(firstRow);
        }
      })
      .on('error', (error) => {
        console.error(`Error reading CSV file: ${error.message}`);
        reject(error);
      });
  });
}

Set reporting structure

Use projectName to group related tests under the same project on the dashboard. Use testName to group multiple runs of the same test.
Both projectName and testName must remain consistent across different runs of the same test.
You can use the following characters in projectName and testName:

  • Letters (A–Z, a–z)
  • Digits (0–9)
  • Periods (.), colons (:), hyphens (-), square brackets ([]), forward slashes (/), at signs (@), ampersands (&), single quotes ('), and underscores (_)
    All other characters are ignored.

Capture response details

Set to captureErrorResponses to true to record full request–response data for failing HTTP calls during the test.

Network throttling

Network throttling enables you to run load tests under real-world network conditions. This helps you understand how your application behaves for users on different connection types.

Simulate common networks or define a custom network profile. Network throttling applies to all virtual users in the test.

Supported modes

The following two modes are supported for configuring network throttling:

Quickly simulate popular network conditions using the following built-in profiles:

  • 3G
  • Slow 4G
  • Fast 4G

Use the following YAML configuration for predefined profiles:

browserstack.yml
Copy icon Copy

Define precise network conditions by configuring individual parameters. Use the following YAML configuration for custom profiles:

browserstack.yml
Copy icon Copy

Configuration parameters

The following table lists the available configuration parameters:

Parameter Type Description Unit Allowed Range
Latency number Simulated network latency ms 0 – 1,000,000
Download number Simulated download bandwidth kb/s 1 – 10,000,000
Upload number Simulated upload bandwidth kb/s 1 – 10,000,000
Packet Loss number Simulated packet loss percentage % 0 – 99

Set thresholds

Use thresholds to determine test pass or fail based on metrics.

Available Metric list and corresponding keys for load testing:

  • Avg. response time - avg-response-time
  • p90 response time - p90-response-time
  • Avg. request rate - avg-request-rate
  • Total requests - total-requests
  • Error % - error-percentage
  • Error count - error-count
  • p75 LCP- p75-lcp
  • p75 FCP- p75-fcp
  • p75 INP- p75-inp
  • p75 CLS- p75-cls
  • p75 TTFB - p75-ttfb

Available conditions:

  • =
  • !=
  • >
  • <
  • >=
  • <=

We assume the following units for the metrics:

  • Avg. response time, p90 response time, INP, TTFB - ms
  • Avg. request rate - reqs/s
  • Error % - %
  • FCP, LCP - s
  • Total requests, Error count, CLS - no unit
browserstack-load.yml

Configure multiple scenarios

The Multiple Scenarios feature allows you to simulate diverse user behaviors by executing different test flows simultaneously within a single load test. You can configure up to 10 distinct scenarios per test using two different configuration modes.

Test selector types

For WebDriverIO tests, the following selector types are supported:

Selector type Description
ConfigFile WebDriverIO XML configuration file path
Individual config mode

Each scenario defines its own VUs, duration (or iterations), and regions independently. This mode provides complete control over each scenario’s load characteristics.

browserstack-load.yml
Copy icon Copy
Load percent mode

Distribute global VUs, duration, and regions across scenarios by percentage. All scenarios must use loadPercent and percentages must sum to 100.

browserstack-load.yml
Copy icon Copy

Run the Load Test

Run the given command to start your tests:

Copy icon Copy

Check out the FAQs section to get answers to commonly asked questions.

View test results

When the test is run, you’ll get a link to the result dashboard where you can analyze key metrics like:

  • Response time
  • Request throughput
  • Web vitals(LCP, CLS, INP, etc.)
  • Errors and bottlenecks

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 Check Circle