-
Clone the repository
git clone https://github.com/browserstack/browserstack-selenium-load-testing-sample.git cd browserstack-selenium-load-testing-sample -
Choose the framework to run
cd into the the respective framework folder, for instance to run the testng sample:
cd testng -
Install Maven dependencies
mvn compile
-
Install BrowserStack CLI
Download the appropriate BrowserStack CLI binary based on your operating system:
-
macOS x86
browserstack-cli-macOS-x86 -
macOS ARM
browserstack-cli-macOS-arm -
Windows x86
browserstack-cli-windows -
Linux x86
browserstack-cli-linux-x86 -
Linux ARM
browserstack-cli-linux-arm
The download is a zip. Extract it and place the
browserstack-clibinary (browserstack-cli.exeon Windows) in the root of your project. On macOS or Linux, also runchmod +x browserstack-cli, since some unzip tools drop the executable bit. -
-
Verify the BrowserStack CLI
Before running the binary, check that it is signed by BrowserStack:
-
macOS: the command must succeed. It only passes if an Apple-issued certificate for BrowserStack's team (
YQ5FZQ855D) signed the binary.codesign --verify --strict -R '=anchor apple generic and certificate leaf[subject.OU] = "YQ5FZQ855D"' ./browserstack-cli -
Windows (PowerShell):
Statusmust beValidand the signer must be BrowserStack.Get-AuthenticodeSignature .\browserstack-cli.exe | Format-List Status, SignerCertificate
If the check fails, do not run the binary.
-
-
Set your credentials
The BrowserStack CLI reads your credentials from environment variables. Copy your username and access key from Account Settings and export them in the shell you run the test from:
On macOS or Linux (bash or zsh), run the lines below. The second one prompts for the key without echoing it, so the key stays out of your shell history:
export BROWSERSTACK_USERNAME="<your-username>" printf 'BrowserStack access key: '; read -rs BROWSERSTACK_ACCESS_KEY; echo; export BROWSERSTACK_ACCESS_KEY
On Windows, run these in PowerShell. The second line prompts for the key in the same way:
$env:BROWSERSTACK_USERNAME = "<your-username>" $env:BROWSERSTACK_ACCESS_KEY = [System.Net.NetworkCredential]::new('', (Read-Host -AsSecureString 'BrowserStack access key')).Password
These variables last only for the current terminal session. If the CLI reports an authentication error, check that both are set in the terminal you run it from.
Never commit your credentials. Leave the
userNameandaccessKeyplaceholders inbrowserstack-load.ymlas they are (the environment variables override them), and keep your access key out of every file you push. If a key is ever exposed, regenerate it from Account Settings. -
Run tests using BrowserStack CLI
./browserstack-cli load run
# Windows (PowerShell) .\browserstack-cli.exe load run
-
View Test Results
Visit the BrowserStack Load-Testing Dashboard to monitor and analyze your test runs.
