From d99cff181ba32541d689c22ed0662a7f684f4102 Mon Sep 17 00:00:00 2001 From: Mihir Rawool Date: Fri, 6 Nov 2026 06:43:04 +0530 Subject: [PATCH 1/4] LTS-5452: README step to set credentials as env vars Export BROWSERSTACK_USERNAME / BROWSERSTACK_ACCESS_KEY in the shell and never commit them; the CLI reads them from the environment. Co-Authored-By: Claude Opus 5.5 --- README.md | 22 ++++++++++++++++++++-- browserstack-load.yml | 3 ++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 917b0a9..a6c2425 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,27 @@ This repo contains samples for running [Playwright](https://playwright.dev/docs/ ## Setup * Clone the repo `git clone https://github.com/browserstack/browserstack-playwright-load-testing-sample.git`. -* Set `BROWSERSTACK_USERNAME` and `BROWSERSTACK_ACCESS_KEY` as environment variables with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings) +* Set your credentials as environment variables, as described in [Set your credentials](#set-your-credentials). * Run `npm i` to install the dependencies. -* Update the same in `browserstack-load.yaml` file. +* Open `browserstack-load.yml` and update it with your load test configuration. + +## Set your credentials + +The BrowserStack CLI reads your credentials from environment variables. Copy your username and access key from [Account Settings](https://www.browserstack.com/accounts/settings) and export them in the shell you run the test from: + +```sh +# macOS / Linux +export BROWSERSTACK_USERNAME="" +export BROWSERSTACK_ACCESS_KEY="" +``` + +```powershell +# Windows (PowerShell) +$env:BROWSERSTACK_USERNAME = "" +$env:BROWSERSTACK_ACCESS_KEY = "" +``` + +**Never commit your credentials.** Leave the `userName` and `accessKey` placeholders in `browserstack-load.yml` as 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. ## Running your tests diff --git a/browserstack-load.yml b/browserstack-load.yml index 08b44a7..b126f29 100644 --- a/browserstack-load.yml +++ b/browserstack-load.yml @@ -1,7 +1,8 @@ # ============================= # Set BrowserStack Credentials # ============================= -# Add your BrowserStack userName and accessKey here or set BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY as env variables. +# Set BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY as env variables. They override the placeholders below. +# Do not paste your real access key into this file: it is easy to commit and push by mistake. userName: BROWSERSTACK_USERNAME accessKey: BROWSERSTACK_ACCESS_KEY From 692786d185ed4203817ea9a62f76947752b6d985 Mon Sep 17 00:00:00 2001 From: Mihir Rawool Date: Fri, 6 Nov 2026 07:13:27 +0530 Subject: [PATCH 2/4] LTS-5452: address review on the credentials step Hidden prompt for the access key so it stays out of bash/zsh and PSReadLine history (CodeRabbit); note the variables last for the current session and how to spot an unset one; per-repo fixes from the code review. Co-Authored-By: Claude Opus 5.5 --- README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a6c2425..c1eaa95 100644 --- a/README.md +++ b/README.md @@ -15,22 +15,27 @@ This repo contains samples for running [Playwright](https://playwright.dev/docs/ The BrowserStack CLI reads your credentials from environment variables. Copy your username and access key from [Account Settings](https://www.browserstack.com/accounts/settings) and export them in the shell you run the test from: ```sh -# macOS / Linux +# macOS / Linux (bash or zsh) export BROWSERSTACK_USERNAME="" -export BROWSERSTACK_ACCESS_KEY="" +# Type the key at the prompt: it is not echoed, and it stays out of your shell history +printf 'BrowserStack access key: '; read -rs BROWSERSTACK_ACCESS_KEY; echo +export BROWSERSTACK_ACCESS_KEY ``` ```powershell # Windows (PowerShell) $env:BROWSERSTACK_USERNAME = "" -$env:BROWSERSTACK_ACCESS_KEY = "" +# Type the key at the prompt: it is not echoed, and it stays out of your PowerShell history +$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 `userName` and `accessKey` placeholders in `browserstack-load.yml` as 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. ## Running your tests -- To run the sample tests in parallel across the platforms specified in the `browserstack-load.yaml`, run `npx browserstack-cli load run`. +- To run the sample tests in parallel across the platforms specified in the `browserstack-load.yml`, run `npx browserstack-cli load run`. ## Notes * You can view your test results on the [BrowserStack Load-Testing dashboard](https://load.browserstack.com/projects) From aa5583bfc7b53d0b437156d67f03a7c471d02c8c Mon Sep 17 00:00:00 2001 From: Mihir Rawool Date: Fri, 6 Nov 2026 07:32:22 +0530 Subject: [PATCH 3/4] LTS-5452: one-line key prompt; review follow-ups Prompt and export on one line, so pasting the block can't feed the export line to read. Robot: per-OS signature check, .gitignore for the CLI binary. Selenium: ignore browserstack-cli.exe. Co-Authored-By: Claude Opus 5.5 --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index c1eaa95..c50db92 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,7 @@ The BrowserStack CLI reads your credentials from environment variables. Copy you # macOS / Linux (bash or zsh) export BROWSERSTACK_USERNAME="" # Type the key at the prompt: it is not echoed, and it stays out of your shell history -printf 'BrowserStack access key: '; read -rs BROWSERSTACK_ACCESS_KEY; echo -export BROWSERSTACK_ACCESS_KEY +printf 'BrowserStack access key: '; read -rs BROWSERSTACK_ACCESS_KEY; echo; export BROWSERSTACK_ACCESS_KEY ``` ```powershell From f81f62a98947c4e037494895fa1b718dca0e8e16 Mon Sep 17 00:00:00 2001 From: Mihir Rawool Date: Fri, 6 Nov 2026 07:47:31 +0530 Subject: [PATCH 4/4] LTS-5452: shell labels in prose; .exe in the binary note zsh (macOS default) has interactive_comments off, so pasted '#' lines printed errors; the labels now sit outside the sh fences. The placement note names browserstack-cli.exe for Windows. Co-Authored-By: Claude Opus 5.5 --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c50db92..bd074eb 100644 --- a/README.md +++ b/README.md @@ -14,17 +14,17 @@ This repo contains samples for running [Playwright](https://playwright.dev/docs/ The BrowserStack CLI reads your credentials from environment variables. Copy your username and access key from [Account Settings](https://www.browserstack.com/accounts/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: + ```sh -# macOS / Linux (bash or zsh) export BROWSERSTACK_USERNAME="" -# Type the key at the prompt: it is not echoed, and it stays out of your shell history 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: + ```powershell -# Windows (PowerShell) $env:BROWSERSTACK_USERNAME = "" -# Type the key at the prompt: it is not echoed, and it stays out of your PowerShell history $env:BROWSERSTACK_ACCESS_KEY = [System.Net.NetworkCredential]::new('', (Read-Host -AsSecureString 'BrowserStack access key')).Password ```