Skip to main content

BrowserStack SDK - FAQs

This section addresses the most frequently asked questions about BrowserStack SDKs. If you have a question that’s not covered here, let us know:

How to toggle between BrowserStack and Local Setup when using BrowserStack SDK?

Based on the shell, use the following commands to easily toggle between local and BrowserStack runs:

  • If using Powershell
Copy icon
  • If using Command Prompt
Copy icon
  • If using Git Bash/MacOS/Linux
Copy icon

If capabilities are defined both in the browserstack.yml file and in test scripts, which ones are prioritized?

If you have capabilities declared in both the browserstack.yml file and in test scripts, the SDK merges these capabilities. However, if you have similar capabilities mentioned in both these locations, the capabilities in the browserstack.yml file take precedence.

When using BrowserStack Local, do I need to explicitly pass the local identifier?

No. The SDK handles this automatically for you.

Does the SDK support W3C or the JSON wire protocol?

The SDK supports both.

I am using local webdriver. Do I need to edit my test scripts to create remote webdriver?

No, the SDK intercepts all types of webdrivers and overrides them to point to BrowserStack’s remote grid.

Where do I add capabilities?

We recommend adding all capabilities in the browserstack.yml file, but you can also configure them in your test script. SDK uses the order of precedence logic to ensure capabilities are set correctly.

How do I integrate my CI/CD setup with BrowserStack SDK?

The steps to integrate with CI/CD tools are the same, whether you integrate using SDK or manually. Check out our documentation to learn more.

Which CLI args/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>

Please note that CLI arguments take precedence over ENV variables

How to handle multiple config files in BrowserStack SDK?

The BrowserStack SDK enables you to maintain different configurations for different projects or folders within your test suites, by supporting multiple config files. This means, you can specify different platforms and capabilities for different tests, without having to update a single config file for the entire suite.
You can specify which config file is to be used using any one of the following methods:

Using CLI args

To use a specific config file with CLI args, simply add the browserstack.config flag followed by the path(relative/absolute) to the desired config file in the run command.

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

Using Environment Variables

To use a specific config file with environment variables, set the BROWSERSTACK_CONFIG_FILE variable to the path(relative/absolute) of the desired config file.

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

Please note that CLI arguments take precedence over ENV variables

How to fix the Java static WebDriver issue?

Declaring WebDriver static can lead to IDLE_TIMEOUT. From browserstack-java-sdk@1.3.0 onwards, enabling the staticWebDriver: true flag in the browserstack.yml fixes this issue.

At present, the default value is set to false to make it an experimental feature.

Is the C# debugger supported with SDK?

Yes, Debugger is supported after browserstack-sdk@1.0.2 and BrowserStack.TestAdapter@0.1.0.

SDK spawns as many test processes as the number of platforms you want to test on. Debugger is attached to the first platform mentioned on browserstack.yml. To attach the debugger to 2nd platform, 1st platform needs to be removed from platforms array in browserstack.yml.

Important: The Debugger is currently only supported for Windows.

NodeJS - How to load environment variables from a .env file?

You can load custom environment variables into your Node SDK project from an external .env file. Set the path to your .env file (you can use both relative and absolute paths) in your browserstack.yml file. Here is a sample test.env file in a sample path:

envFile: \sample-path\test.env # load custom environment

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