Load testing with Selenium
Run a load test using Selenium scripts on BrowserStack Load Testing
Prerequisites
- BrowserStack Username and Access key. You can find this under your account profile.
- An existing automated test suite written in Selenium JUnit, TestNG, or TestNG Cucumber.
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.

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

Upload scripts
In this step, upload your Selenium automation project as a ZIP file. Select your framework (for example, Selenium - TestNG) from the dropdown, then drag and drop your ZIP file (up to 250MB) or click to select it.
Before you zip and upload your Selenium automation projects, replace local WebDriver instances (such as new ChromeDriver()) with RemoteWebDriver to run tests on the remote setup. Set the remote URL to http://localhost:4444/wd/hub.
Example
RemoteWebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), caps);

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 TestNG config file) and any other dependencies (path of pom.xml) identified in your project.

Ensure that your pom.xml and TestNG 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
.envfiles (up to 5 MB each) by dragging and dropping into the upload area:- You can upload
.env,.yaml,.yml,.json,.properties,.ini, or.cfgfiles. - After upload, the variables become available to your test run.
- You can upload
- 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

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.csvfiles have headers. The system automatically stores up to five versions of each file.

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

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

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.

- 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.

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.

- 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.

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.

Set thresholds
Use thresholds to decide test status based on performance and reliability metrics:
- Click Thresholds to expand the section.
- Click Add metric for criteria and choose a metric.
- 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.

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.

For Selenium tests, the following selector types are supported:
| Selector type | Description |
|---|---|
| Config file | Selenium configuration file path (string) |
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:
- On your Load Testing dashboard, scroll to the Throttle Network section.
- Choose among the predefined profiles for 3G, Slow 4G, and Fast 4G.

Follow these steps to set up custom network throttling:
- On your Load Testing dashboard, scroll to the Throttle Network section and select Custom Values.
- Input your desired values 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 |
Download the BrowserStack Load Testing CLI
Download the CLI based on your operating system and place it at the root directory of your Selenium project:
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:
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 Selenium for a load test using Selenium test suite.
Specify the language
Set the language to java.
Currently, only Selenium with Java TestNG, and TestNG Cucumber is supported.
Specify the test framework
Set the framework to junit, testng, or, cucumber-testng for TestNG Cucumber, depending on your preferred testing framework.
Specify the paths to your TestNG configuration file and pom.xml file
The files block specifies the key files required to install dependencies and define which tests should be executed.
- Under
dependencies, list the paths to required files for installing dependencies. For Java (Maven) projects, include the path to yourpom.xmlfile. Note: Only Maven projects are currently supported. - Under
testConfigs, list the paths to test configuration files. For TestNG, add the path to your testng.xml file. Note: Only one configuration file is supported per test run. If you specify multiple files, only the first one will be used.
Ensure all referenced files are relative to the project root.
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 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
loadProfileblock, settypetorampingto enable staged traffic changes. - Under
stages, add one or more steps:-
type: rampincreases or decreases VUs fromfromtotooverduration. Result: VUs change linearly until they reach the target. -
type: holdkeeps VUs constant forduration. 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
vusis high enough to cover the largest stagetovalue. If not, the test cannot reach the target VUs.
Validation rules:
- Each stage must include
type,from,to, andduration. - Use valid time units (
Xs,Xm,Xh). Example:45s,10m,1h5m. -
fromandtomust be non-negative integers and must not exceed the globalvuslimit. - 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
durationif 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.
Set Regions
- Use the
loadzonesub-config to specify each region. For each region, set the traffic percentage using thepercentsub-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 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.
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 Selenium tests, the following selector types are supported:
| Selector type | Description |
|---|---|
| ConfigFile | Selenium 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.
Load percent mode
Distribute global VUs, duration, and regions across scenarios by percentage. All scenarios must use loadPercent and percentages must sum to 100.
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:
Define precise network conditions by configuring individual parameters. Use the following YAML configuration for custom profiles:
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
Use RemoteWebDriver
Replace local WebDriver instances (such as new ChromeDriver()) with RemoteWebDriver to run tests on the remote setup.
Set the remote URL to http://localhost:4444/wd/hub.
Run the Load Test
Run the given command to start your test:
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
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!