Skip to main content

Supported CLI Args and ENV Variables in Automate

Which CLI args or ENV Variables can be used with BrowserStack SDK?

The following table displays all the supported CLI arguments with corresponding ENV variables:

CLI args list ENV Variables list
browserstack.username BROWSERSTACK_USERNAME
browserstack.user_name BROWSERSTACK_USER_NAME
browserstack.accesskey
browserstack.access_key
BROWSERSTACK_ACCESS_KEY
browserstack.projectName BROWSERSTACK_PROJECT_NAME
browserstack.buildName BROWSERSTACK_BUILD_NAME
browserstack.buildIdentifier BROWSERSTACK_BUILD_IDENTIFIER
browserstack.parallelsPerPlatform
browserstack.ppp
BROWSERSTACK_PARALLELS_PER_PLATFORM
browserstack.local BROWSERSTACK_LOCAL
browserstack.localIdentifier BROWSERSTACK_LOCAL_IDENTIFIER
browserstack.rerunTests BROWSERSTACK_RERUN_TESTS
browserstack.automation BROWSERSTACK_AUTOMATION
browserstack.app BROWSERSTACK_APP

Following is an example of how it can be used:

Using CLI args

Framework Prefix Example command
Java -D mvn test -P sample-test -Dbrowserstack.buildName="MySampleBuild"
NodeJS – – npm run sample-test -- --browserstack.buildName "MySampleBuild"
Or
npm run sample-test -- --browserstack.buildName="MySampleBuild"
Python browserstack-sdk python ./tests/test.py --browserstack.buildName "MySampleBuild"
C# dotnet browserstack-sdk --browserstack.buildName "MySampleBuild"

Using Environment Variables

OS Set env variable Set env variable in a single command
MacOS/Linux export BROWSERSTACK_BUILD_NAME="MySampleBuild" BROWSERSTACK_BUILD_NAME="MySampleBuild" <your-test-command>
Windows Powershell $env:BROWSERSTACK_BUILD_NAME "MySampleBuild" $env:BROWSERSTACK_BUILD_NAME="MySampleBuild"; <YOUR_TEST_COMMAND>
Windows cmd set BROWSERSTACK_BUILD_NAME "MySampleBuild" set BROWSERSTACK_BUILD_NAME="MySampleBuild"&& <YOUR_TEST_COMMAND>

In addition to specifying values directly in the browserstack.yml configuration file, BrowserStack supports fetching values dynamically from environment variables. This allows for greater flexibility in managing configuration settings based on your environment.

To access environment variables within the browserstack.yml file, use the following syntax:

terminal
Copy icon Copy snippet

Replace ENV_VARIABLE with the name of the environment variable you wish to reference.

Example

Suppose you want to specify the testing framework to be used in your configuration. Instead of hardcoding the framework value in browserstack.yml, you can fetch it from an environment variable.

Step 1: Set the Environment Variable

Set the desired framework as an environment variable using your terminal:

Copy icon Copy snippet
Copy icon Copy snippet
Copy icon Copy snippet
Step 2: Reference the Environment Variable in browserstack.yml

In your browserstack.yml file, use the environment variable syntax to specify the framework:

browserstack.yml
Copy icon Copy snippet

Now, when BrowserStack reads the browserstack.yml file, it will dynamically replace ${MY_FRAMEWORK} with the value of the MY_FRAMEWORK environment variable, which is testng in this example.

You can use any valid environment variable name, and it’s not limited to a predefined list.

Note that CLI arguments take precedence over ENV variables.

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