ScreenshotNeo

BlogHow-to

How to Improve BrowserStack SDK Automation Tests

Improve BrowserStack SDK test runs with a focused platform matrix, safe parallelism, reliable Local connections, and useful failure diagnostics.

By the ScreenshotNeo team4 October 20268 min read

To improve BrowserStack SDK automation tests, choose a platform matrix that reflects the browsers and devices your users need, increase parallelism only after making tests independent, configure BrowserStack Local only for private targets, and use retries to diagnose intermittent failures rather than conceal them. Then give each run clear identifiers and retain the diagnostics needed to trace failures.

BrowserStack SDK integrates with a test suite and applies configuration at runtime. It can direct execution to BrowserStack, select platforms, configure parallelism, and enable Local testing; it does not automatically fix flawed tests. BrowserStack’s SDK overview explains the execution model and framework support.

1. Check the SDK, language, and runner combination

Before changing test code or CI, confirm that BrowserStack documents support for your language and framework, and that the specific feature you want is supported by that combination. The SDK framework list includes Java, Node.js, C#, and Python runners, but orchestration features can have narrower support. For example, BrowserStack’s current orchestration page lists TestNG, Pytest, Jest, and NUnit for its strategies, with additional frameworks supported for some individual strategies.

  1. Confirm the SDK integration guide for your language and runner.
  2. Keep the existing tests and first validate a small run on one platform.
  3. Store BrowserStack credentials as environment variables in local and CI environments. Do not commit them in configuration or source control.
  4. After the single-platform run works, change the matrix or concurrency in a separate step.

When SDK setup cannot connect or start, use BrowserStack’s SDK Debug Utility to check credentials, project directory, language selection, and connectivity.

2. Build a platform matrix that answers a product question

The platforms list controls which browser, operating system, and device combinations receive the suite. Every configured platform receives the tests unless test-script logic selects tests conditionally. More combinations can add coverage, but redundant combinations add execution work without necessarily improving release confidence.

  • Include combinations tied to supported users, usage, or known compatibility risk.
  • Keep a small pull-request matrix for core journeys when fast feedback matters.
  • Run broader scheduled or pre-release coverage when it fits the team’s release process.
  • When a failure occurs, reproduce it on the same browser or device before expanding the matrix.

Here is a representative configuration shape. Replace the sample platform values with combinations supported by your project and current BrowserStack availability. The configuration uses placeholder credentials; supply real values securely through the supported setup for your integration.

userName: YOUR_USERNAME
accessKey: YOUR_ACCESS_KEY
projectName: checkout
buildName: pull-request-123
parallelsPerPlatform: 1
platforms:
  - os: Windows
    osVersion: "11"
    browserName: Chrome
    browserVersion: latest
  - os: OS X
    osVersion: Sonoma
    browserName: Safari
    browserVersion: latest

Configuration keys and platform capabilities vary across SDK integrations. Check the current Automate capabilities reference and the documentation for your selected runner. In general, root-level capabilities apply across platforms and platform-specific values belong in the relevant platform entry. BrowserStack documents that when a capability is defined in both the test script and browserstack.yml, the YAML value takes precedence.

3. Add parallelism only when tests are independent

Cross-browser or device coverage and test-level concurrency are separate settings. The platform list determines the combinations; parallelsPerPlatform determines how many non-sequential test executions run per platform. BrowserStack’s documented configuration example of three platforms and two parallels per platform results in six configured threads. That is a concurrency count, not a guaranteed speedup.

A useful estimate is:

configured cloud threads = number of platform combinations × parallelsPerPlatform

Check runner worker settings too: the SDK, framework, CI workers, and account capacity all affect actual concurrency. Start with one, then increase in measured steps on a representative suite. Compare elapsed time, failure rate, and retry rate at each step.

Before increasing concurrency, confirm that tests can run in any order and at the same time:

  • Give each worker isolated accounts, records, and other mutable test data.
  • Remove dependencies on another test’s setup or cleanup.
  • Make setup and cleanup safe when a test fails or is interrupted.
  • Check application and test-environment rate limits and capacity.
  • Keep CI runner workers consistent with the concurrency you intend to use.

Shared state, rate limits, or an overloaded staging environment can turn additional threads into harder-to-diagnose failures. If tests must remain sequential, do not use test-level parallelism for them; platform coverage can still be configured separately.

4. Use BrowserStack Local for private environments

BrowserStack Local provides a connection for testing a development, staging, or otherwise private target that cloud browsers cannot reach directly. It is a connectivity feature, not a test-stability feature. BrowserStack describes Local as an outbound encrypted tunnel, so the private target does not need to be exposed to the public internet.

The SDK can manage Local as part of a run. Depending on the integration, you can also start the Local binary yourself and configure the SDK to connect to that existing tunnel. If you use a local identifier, it must match between the tunnel and test configuration. Refer to your runner’s current SDK configuration guide and the Local Testing overview for the supported setup.

  • Use Local only when the target is private or otherwise inaccessible from the BrowserStack cloud.
  • For a browser session that starts but cannot load the application, check tunnel status, identifier, host and port, and network or proxy restrictions.
  • Inspect tunnel logs and verify the target is reachable from the machine running the tunnel.
  • Do not treat a successful tunnel connection as evidence that the application or test is correct.

5. Use retries to classify failures, not erase them

Automatic reruns can show whether a failure persists or appears intermittent. A passing retry does not prove the test is stable: the first failure remains evidence that the run can fail. Keep the original result visible, track retry outcomes, and fix or quarantine repeatedly flaky tests under an explicit team policy.

BrowserStack Automate documents strategies including auto reruns, fail fast, running failures only, prioritizing failures, and skipping flaky or failing tests. Support differs by framework, and strategies have combination rules. Check the current test orchestration documentation before enabling a strategy.

For a supported configuration, the documented auto-rerun setting has this shape:

testOrchestrationOptions:
  retryTestsOnFailure:
    enabled: true
    maxRetries: 3

Set a retry limit that helps triage without making failures disappear into repeated attempts. BrowserStack documents that auto reruns and fail fast can be combined with other orchestration strategies; other strategies have mutual-exclusion rules. Verify the current framework and combination table before relying on a particular setup.

6. Make failures easier to diagnose

Give builds and sessions stable, informative names and attach project or build metadata supported by your integration. Retain useful diagnostics, such as browser console or network logs, where the framework and configuration support them. Exact option names vary by SDK.

For each failure, determine whether the likely cause is the application, test code, test data, browser capability, environment capacity, or Local connectivity. Reproduce it on the same platform first. Keep the first attempt and retry outcomes available together so intermittent failures remain visible.

7. Measure the effect of each change

Change one major execution setting at a time. On the same representative suite, record elapsed duration, failures, retry outcomes, and whether the result is reproducible. More threads can reduce elapsed time when work is independent and capacity is available, but there is no universal speed percentage: the result depends on the suite, runner, account capacity, and test environment.

Keep cost and reliability tied to the actual configuration. A larger matrix runs more platform combinations; increased concurrency uses more simultaneous capacity. Avoid spending that capacity on combinations that do not answer a coverage question, and investigate repeated failures before increasing retries or suppressing tests.

8. Troubleshoot common problems

Symptom Likely cause What to check
SDK cannot authenticate or start a session Missing, incorrect, or unavailable credentials; setup or connectivity issue Confirm environment variables and secret injection in CI. Run the BrowserStack SDK Debug Utility and inspect its credential and connectivity checks.
Tests run on an unexpected browser or OS Platform entry is wrong, unsupported, or overridden by configuration precedence Review the platform values and capability names. BrowserStack documents that browserstack.yml takes precedence over duplicate script capabilities.
Concurrency is lower or higher than expected Platform count, parallelsPerPlatform, framework workers, or account capacity do not match Recalculate platform combinations × parallels per platform; then compare with runner worker settings and available capacity.
Parallel runs fail intermittently Tests share accounts or mutable records, rely on order, or overload the environment Isolate data per worker, make cleanup safe, check rate limits, and reduce concurrency to identify the source.
Session starts but the private app does not load Local tunnel is absent, misconfigured, or unable to reach the host Check the tunnel process and logs, identifier match, host and port, DNS, firewall, and proxy configuration.
Retries make the build appear green while defects recur Retry results are obscuring the original failure or flaky tests have no owner Keep first-attempt failures visible, track retries, and assign a fix or quarantine decision under a clear policy.
An orchestration option is ignored The strategy is unsupported by the runner or conflicts with another strategy Check the current framework support and strategy-combination table in BrowserStack’s orchestration documentation.

9. Capture screenshots without building a browser-capture service

For test runs where you need a website screenshot as a separate artifact or reference, ScreenshotNeo is an alternative to try first: it returns clean screenshots and bills only clean shots. It is a website screenshot API and MCP server, separate from BrowserStack SDK test execution.

Or skip the browser setup

Make one GET request with the page URL. See the ScreenshotNeo API documentation for parameters and response details.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
    timeout=90,
)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
  • Cookie banners are accepted and removed before the shot; newsletter popups and chat widgets are removed too. Each cleanup step can be turned off.
  • Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing; response headers identify the page verdict and billing status.
  • An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.
  • The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 screenshots.

Sign up for 1,000 free screenshots a month, with no card.

Frequently asked questions

Does the SDK rewrite my tests?

The SDK integrates at runtime and uses configuration to affect execution. It does not make a test logically correct or remove the need to fix flaky test design.

Should every test run on every platform?

Only if that coverage is useful for the test’s purpose. A focused matrix can give faster feedback; broader coverage can run on a schedule or before release.

Does a passing retry mean the original failure can be ignored?

No. It shows that a later attempt passed. Preserve the first failure and investigate recurring intermittent behavior.

Can I use Local to fix a slow or flaky test?

Local addresses access to private targets. It does not fix test timing, shared state, or application instability.

Primary references