Sample repository for Playwright framework to do load testing
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_KEYOn 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')).PasswordThese 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. Keep your access key out of browserstack-load.yml and every other file you push. If a key is ever exposed, regenerate it from Account Settings.
-
Download the BrowserStack CLI for your operating system. The download is a zip: extract it and place the
browserstack-clibinary (browserstack-cli.exeon Windows) in the root of this project. On macOS or Linux, also runchmod +x browserstack-cli, since some unzip tools drop the executable bit. -
On macOS and Windows, check that the binary is signed by BrowserStack before running it. On macOS the command must succeed: it only passes if an Apple-issued certificate for BrowserStack's team (
YQ5FZQ855D) signed the binary; on Windows,Statusmust beValidwith BrowserStack as the signer. If the check fails, do not run the binary. There is no signature check for the Linux build.codesign --verify --strict -R '=anchor apple generic and certificate leaf[subject.OU] = "YQ5FZQ855D"' ./browserstack-cli# Windows (PowerShell) Get-AuthenticodeSignature .\browserstack-cli.exe | Format-List Status, SignerCertificate
-
Start the test:
./browserstack-cli load run
# Windows (PowerShell) .\browserstack-cli.exe load run
-
Dependencies are hash-pinned.
requirements.txtis a lock with a hash for every package, so pip refuses anything that doesn't match. Edit the direct dependencies inrequirements.in, then regenerate the lock:uv pip compile requirements.in --universal --python-version 3.10 --generate-hashes -o requirements.txt
-
Set thresholds for your own SLA.
browserstack-load.ymlships an error-rate and a p95 response-time threshold. Without thresholds every run reports as passed, however the application behaves. -
Every VU logs in as the same demo user. That's fine against bstackdemo.com. Against your own application, give each VU its own test account. Concurrent sessions sharing one account race on the same cart and orders, and that can hide real failures.