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

Environment variables

Use environment variables in BrowserStack Load Testing to parameterize tests and avoid hard-coding secrets

You can set environment variables to pass dynamic values to your load tests, such as API keys, user credentials, or configuration settings.

Depending on your preferred method, select any one of the following to set environment variables:

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

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.

browserstack-load.yml
env:
  sources:
   - path/to/env/file
  variables:
   - name: "variable1"
     value: "value1"
   - name: "variable2"
     value: "value2"

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