October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk7 min

How to Run Playwright and Puppeteer Tests on BrowserStack

A practical guide to BrowserStack Automate for Playwright and Puppeteer, with framework-specific setup, target selection, parallel runs, and troubleshooting.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

BrowserStack Automate runs Playwright and Puppeteer tests in hosted browsers, but the setup differs: BrowserStack’s Playwright guide uses a sample repository and environment variables, while Puppeteer connects to BrowserStack’s Chrome DevTools Protocol (CDP) endpoint. Choose the framework-specific route below, select a supported browser and operating system from its live matrix, then inspect the Automate dashboard for results and diagnostics.

Choose the BrowserStack route for your framework

Question Playwright Puppeteer
How the remote browser is reached Start with BrowserStack’s documented sample repository and run its parallel sample. Connect with puppeteer.connect() to wss://cdp.browserstack.com/puppeteer, passing encoded browser and OS capabilities.
Integrating an existing suite The cited quickstart documents a sample route; its command is not a universal command for every Playwright project. For a Jest-based suite, BrowserStack documents the browserstack-node-sdk integration route.
Choosing browser and OS targets Use the Playwright support table and its capability names. Use the Puppeteer support table and its capability names.
Reporting pass or fail Consult the framework’s sample and result flow. Send an explicit BrowserStack executor command to mark the session passed or failed; a successful connection alone does not report the test outcome.

Browser and OS availability varies by framework and changes over time. Avoid copying a capability from the other framework or relying on an old browser-version example.

As an Amazon Associate I earn from qualifying purchases.

Run BrowserStack’s Playwright sample

  1. In a terminal, clone BrowserStack’s sample repository and enter it:
    git clone https://github.com/browserstack/playwright-browserstack
    cd playwright-browserstack
  2. Install the repository’s dependencies using the package manager and instructions in its README. The documented route is for that sample, not a drop-in command for every existing Playwright project.
  3. Set the BrowserStack credentials as environment variables. Use your account username and access key; do not commit either value to source control.
    export BROWSERSTACK_USERNAME="YOUR_USERNAME"
    export BROWSERSTACK_ACCESS_KEY="YOUR_ACCESS_KEY"

    On Windows PowerShell, set them for the current session with $env:BROWSERSTACK_USERNAME="YOUR_USERNAME" and $env:BROWSERSTACK_ACCESS_KEY="YOUR_ACCESS_KEY".

    What’s actually slowing this PC down?

    Pick the symptom - the matching free tool is one click away.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  4. Run the sample command documented by BrowserStack:
    node parallel_test.js
  5. When the run finishes, open the BrowserStack Automate dashboard and review the completed sessions.

Before adapting the sample to your project, check the Playwright supported versions, browsers, and OS table. It covers framework versions, OS values, browser names and versions, and device names. The examples distinguish branded Chrome and Edge from Playwright’s bundled Chromium, Firefox, and WebKit identifiers; use the documented name for the browser you intend to test.

Connect Puppeteer to a remote BrowserStack browser

BrowserStack’s sample route uses Puppeteer’s CDP connection rather than launching a browser on the local machine. Set credentials in the environment, construct the documented capabilities for a supported browser and OS, and pass the encoded capabilities when connecting.

const puppeteer = require('puppeteer');

const username = process.env.BROWSERSTACK_USERNAME;
const accessKey = process.env.BROWSERSTACK_ACCESS_KEY;
if (!username || !accessKey) {
  throw new Error('Set BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY');
}

// Replace these example target values with capability names and values
// from BrowserStack's current Puppeteer support table.
const capabilities = {
  'browser': 'chrome',
  'browser_version': 'latest',
  'os': 'Windows',
  'os_version': '10',
};

const query = new URLSearchParams({
  'key': accessKey,
  'capabilities': JSON.stringify(capabilities),
});
const endpoint = `wss://cdp.browserstack.com/puppeteer?${query}`;

(async () => {
  const browser = await puppeteer.connect({ browserWSEndpoint: endpoint });
  let passed = false;
  try {
    const page = await browser.newPage();
    await page.goto('https://example.com', { waitUntil: 'domcontentloaded' });
    if (!(await page.title()).includes('Example Domain')) {
      throw new Error('Unexpected page title');
    }
    passed = true;
  } finally {
    // Puppeteer assertions run client-side. Report the result explicitly
    // using BrowserStack's executor command, as in its current quickstart.
    const status = passed ? 'passed' : 'failed';
    const reason = passed ? 'Assertions passed' : 'Test assertion failed';
    const page = (await browser.pages())[0];
    if (page) {
      await page.evaluate((status, reason) => {
        return fetch('https://www.browserstack.com/automate/api/v1/sessions', {
          method: 'POST',
          headers: { 'Content-Type': 'application/json' },
          body: JSON.stringify({
            action: 'setSessionStatus',
            arguments: { status, reason },
          }),
        });
      }, status, reason).catch(() => {});
    }
    await browser.disconnect();
  }
})();

Use BrowserStack’s Puppeteer sample build quickstart for its current connection and executor-command example. The endpoint and capability field conventions are service-specific; check that page rather than treating the illustrative target values above as a current support guarantee. BrowserStack explains that Puppeteer assertions run client-side, so it cannot infer pass or fail from the remote session automatically. Its sample sends a browserstack_executor command through the page to set the session status. Follow that documented command pattern in your own teardown or result-reporting path so failed assertions do not appear as successful sessions.

For a Jest-based existing suite, BrowserStack’s Puppeteer Node SDK integration guide documents installing browserstack-node-sdk as a development dependency, running npx setup to generate browserstack.yml, choosing supported platforms in that configuration, and executing the suite through the SDK. That guide states Node.js 14 or later and npm as prerequisites; verify the live guide for current requirements before using them.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Select targets and configure parallel runs

Build a test matrix from the browsers and operating systems your users actually need. For each framework, select combinations supported by its own table: Playwright browsers and OS or Puppeteer browsers and OS. Capability names and available versions are not interchangeable assumptions.

In the documented Puppeteer parallel model, each capability entry represents a separate remote session. Playwright’s cited sample is run as a parallel build with node parallel_test.js. Multiple browser/OS sessions can cover a matrix in parallel, but the number that actually run concurrently depends on the parallel limit attached to your BrowserStack account. Parallel execution may reduce elapsed time when account capacity and test workload permit; it does not change what each test covers.

Test a private or locally hosted application

For a private site or an app that is not publicly reachable, BrowserStack’s Puppeteer getting-started material says to establish a secure BrowserStack Local Testing tunnel first. The tunnel setup has its own commands and options, so use BrowserStack’s Local Testing instructions for the current procedure rather than inventing flags or assuming the remote browser can reach your machine directly.

Find failures and diagnose remote runs

After a run, open the session in Automate and use the available artifacts to distinguish a test failure from a remote-browser or infrastructure problem. BrowserStack describes logs, console output, video, and network information as debugging data accessible through the dashboard or API.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Assertion failure: inspect the test output and page state; for Puppeteer, verify your executor status-reporting path marks the session failed when an assertion throws.
  • Navigation or load failure: check the session’s logs and network information to see whether the page request or a dependent resource failed.
  • Unexpected browser behavior: confirm the session used the browser, version, OS, and framework combination you intended, using the relevant live support table.
  • Missing or misleading result status: distinguish a connected session from a passed test. In Puppeteer, report pass/fail explicitly through the documented executor flow.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting common setup problems

Symptom Likely cause What to check
Authentication or connection failure A credential is missing, incorrect, or not available in the process environment. Confirm both BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY are set in the shell that launches the test. Keep secrets out of committed files.
Unsupported capability or browser target A browser, OS, version, or capability name is not supported for that framework or is outdated. Copy the current target names from the Playwright or Puppeteer support table for the framework in use.
Playwright sample command fails in an existing project node parallel_test.js belongs to BrowserStack’s sample repository, not every Playwright project. Run the command from the cloned sample repository, or follow the applicable BrowserStack integration instructions for your own project.
Puppeteer session is connected but shown without the expected result Client-side assertions were not reported to BrowserStack. Ensure teardown sends the documented executor status command for both pass and failure paths.
Remote browser cannot access an internal app The app is not publicly reachable from the hosted browser. Establish BrowserStack Local Testing using its current instructions, then retry.
Fewer sessions run at once than the matrix contains Account concurrency entitlement limits active sessions. Check the account’s permitted parallel capacity; a configured matrix does not itself guarantee simultaneous execution.

Or skip the browser setup

If you need a website screenshot rather than a remote Playwright or Puppeteer test, ScreenshotNeo is a screenshot API and MCP server. One GET request returns a PNG, JPEG, WebP, or PDF. Its cleanup accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients.

For a quick screenshot, replace the target URL in this cURL request. See the ScreenshotNeo API documentation for options and response details.

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

ScreenshotNeo includes 1,000 screenshots per month free with no card, and paid plans start at $5 for 3,000. Sign up for the free plan.

Frequently Asked Questions

Can I run both frameworks in the same BrowserStack account?

Yes. BrowserStack Automate documents hosted-browser routes for both Playwright and Puppeteer; configure each suite using its framework-specific setup and capabilities.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Does Puppeteer pass/fail status follow automatically from my assertions?

No. Assertions execute on the client side, so report the result through BrowserStack’s documented executor command.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.