A minimal Selenium test that runs on BrowserStack Automate via the BrowserStack Node SDK, wired to run in GitHub Actions.
| File | Purpose |
|---|---|
browserstack.yml |
Where tests run — browser/OS matrix, parallelism, credentials, reporting. |
test/bstack_sample.test.js |
The actual Selenium test (plain code — no hub URL or capabilities). |
package.json |
Deps (browserstack-node-sdk, mocha, selenium-webdriver) and the npm test script. |
.github/workflows/browserstack.yml |
CI pipeline that installs deps and runs the suite. |
The SDK wraps the test runner: browserstack-node-sdk mocha .... At runtime it
intercepts WebDriver creation and redirects your sessions to BrowserStack using
the platforms in browserstack.yml. Your test code stays clean and portable —
the same file runs locally against a real browser if you drop the SDK wrapper.
- Install dependencies:
npm install
- Export your BrowserStack credentials (find them in
Account → Settings):
export BROWSERSTACK_USERNAME="your-username" export BROWSERSTACK_ACCESS_KEY="your-access-key"
- Run the tests:
npm test - Watch the sessions live on the Automate dashboard.
- Push this repo to GitHub.
- Add two repository secrets under
Settings → Secrets and variables → Actions:
BROWSERSTACK_USERNAMEBROWSERSTACK_ACCESS_KEY
- The workflow runs automatically on pushes/PRs to
main, or trigger it manually from the Actions tab (Run workflow).
Edit the platforms: list in browserstack.yml. Add or remove OS/browser
combinations — each entry is one session. Use the
Capabilities Generator
to find valid os / osVersion / browserName / browserVersion values.