Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
browser automation

How to Run Playwright Scripts Online: CI, Cloud Browsers, and Workers

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

To run Playwright online, put your script in an environment that has the matching Playwright package and browser binaries, then execute it in a CI runner, container, hosted browser session, or a runtime such as Cloudflare Workers Browser Run. The right choice depends on whether you need repeatable builds, a remotely managed browser, or a Workers-native workflow. Playwright supports Chromium, Firefox, and WebKit and provides libraries for TypeScript, JavaScript, Python, .NET, and Java.

Choose where the script should run

“Online” can mean several different architectures. Decide what is remote before changing your code.

Approach Best for Checks before you commit
CI runner or container Repeatable tests, scheduled jobs, and repository workflows Operating-system dependencies, browser installation, secrets, artifacts, and whether headed mode is required
Hosted browser session Driving a browser managed by a specialist service from your own script Connection method, Playwright/CDP compatibility, session limits, geography, pricing, and credential handling
Cloudflare Workers Browser Run Workers applications that need browser automation Workers runtime constraints and compatibility with Cloudflare’s adapted Playwright fork

There is no reliable, apples-to-apples price or regional-limit comparison for these options in the documentation cited here. Check each provider’s current terms before selecting one.

Prepare a local script for an online runtime

Use a supported language and browser

Playwright’s official overview covers the Playwright Test runner, the automation library, CLI tooling, and language bindings. Choose the binding that matches your existing script: TypeScript/JavaScript, Python, .NET, or Java. The same project may target Chromium, Firefox, and WebKit, but a remote service or constrained runtime may expose only some engines.

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

Make navigation and cleanup explicit

Online jobs should not depend on a developer’s open desktop session. Set a timeout, wait for a meaningful page state, and always close the browser:

import { chromium } from 'playwright';

const browser = await chromium.launch({ headless: true });
try {
  const page = await browser.newPage();
  await page.goto('https://example.com', { waitUntil: 'domcontentloaded' });
  console.log(await page.title());
} finally {
  await browser.close();
}

Use environment variables for credentials and service URLs; never commit tokens to the repository. Save traces, screenshots, or videos as CI artifacts when a failure needs investigation.

Run Playwright in a CI runner or container

CI is usually the simplest online option: every run starts from a known checkout, installs dependencies, executes the script, and stores evidence. Playwright’s Continuous Integration guide documents provider-specific setup and a public Docker image option for Google Cloud Build.

Install the package and matching browsers

For a Node project, install Playwright and then install its browser binaries:

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.
npm ci
npx playwright install --with-deps

The --with-deps option is useful on Linux runners because it installs required system packages as well as browsers. If you only need one engine, install it explicitly:

npx playwright install chromium

Python projects use the corresponding package and CLI:

python -m pip install playwright
python -m playwright install --with-deps chromium

Follow the exact command for your language and operating system in the official Browsers guide. Each Playwright release expects specific browser binary versions; after upgrading the package, install browsers again rather than assuming an older cache is valid.

Example GitHub Actions job

name: browser-check
on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: npm
      - run: npm ci
      - run: npx playwright install --with-deps chromium
      - run: node scripts/check-page.mjs
        env:
          LOGIN_TOKEN: ${{ secrets.LOGIN_TOKEN }}
      - if: always()
        uses: actions/upload-artifact@v4
        with:
          name: playwright-output
          path: test-results/

Adapt the action versions and Node version to your repository. Keep secrets in the CI provider’s secret store. If your script needs a visible browser, verify that the runner offers a display server; most unattended jobs should remain headless.

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

Control resource use

  • Reuse one browser process and create separate contexts or pages instead of launching a browser for every URL.
  • Limit parallel workers to the CPU and memory available on the runner.
  • Set bounded navigation and assertion timeouts so a dead page cannot consume a job indefinitely.
  • Upload only useful artifacts; videos and traces can be large.

Connect to a hosted browser with CDP

A hosted browser service keeps the browser in a remote session while your code controls it. Browserbase’s Playwright quickstart demonstrates connecting through the Chrome DevTools Protocol (CDP). The exact endpoint, authentication, session lifetime, browser engines, geography, and limits come from the service you choose.

Generic connection pattern

import { chromium } from 'playwright';

const browser = await chromium.connectOverCDP(process.env.BROWSER_CDP_URL);
try {
  const context = browser.contexts()[0] || await browser.newContext();
  const page = await context.newPage();
  await page.goto('https://example.com', { waitUntil: 'domcontentloaded' });
  console.log(await page.title());
} finally {
  await browser.close();
}

Use the provider’s documented URL and token format in BROWSER_CDP_URL. Some services create a context for you; others require one. Do not assume that every Playwright feature, browser engine, or persistent context is available through CDP. Test downloads, file uploads, authentication, popup handling, and tracing in the provider’s environment.

Remote-session failure points

  • Connection refused or expired: create a fresh session and confirm the endpoint has not timed out.
  • Protocol error: check the provider’s supported Playwright version and whether its endpoint is CDP-compatible.
  • Unexpected location or locale: set the service’s region, timezone, and context settings explicitly if offered.
  • Leaked credentials: pass secrets through environment variables and close the session in a finally block.

Use Cloudflare Workers Browser Run carefully

Cloudflare documents a Workers-specific Browser Run integration at its Playwright page. Cloudflare says the Workers team adapted a Playwright fork for this environment. That means a standard desktop Playwright program should not be assumed to work unchanged.

Validate compatibility before migrating

  1. Read the current Browser Run documentation for the supported API surface and binding setup.
  2. Port a small navigation-and-selector test first.
  3. Check unsupported features such as filesystem access, long-lived processes, headed mode, downloads, and browser launch options.
  4. Measure execution time and Workers resource limits with your real pages.

Keep the original CI or hosted-browser path until the Workers version passes the same assertions and produces the artifacts your team needs.

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

Browser installation and version discipline

Playwright’s browser guide states: “Each version of Playwright needs specific versions of browser binaries to operate.” Read the official browser documentation for browser installation, system dependencies, branded browser channels, emulated devices, and selecting a single engine.

Common version mistakes

  • Upgrading playwright but restoring an old browser cache.
  • Installing only Chromium while a project matrix also launches Firefox or WebKit.
  • Using a system browser whose version is outside the range tested by your Playwright package.
  • Installing browsers in one CI step and running in a different image or container.

Pin package versions in your lockfile, install browsers in the same image that runs the script, and make the browser matrix explicit in configuration.

Make online runs reliable

Wait for application state, not arbitrary sleeps

Prefer locators and assertions that describe the state you need. A short delay can hide a race on one machine and fail on another. Use network-idle waits only when the application’s background traffic makes them appropriate; some sites never become truly idle.

Handle authentication safely

Use test accounts or short-lived tokens. Store Playwright storage state as a protected CI artifact only when necessary, and delete it after the job. Never print cookies, authorization headers, or page content containing secrets.

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

Capture evidence on failure

Record the URL, browser engine, Playwright version, and runner image. A screenshot, trace, console log, and network error often distinguish an application defect from a missing dependency or transient service failure.

Respect target sites

Online execution does not remove the need to follow a site’s terms, robots policy, authentication rules, and rate limits. Add retries only for demonstrably transient failures; retries can multiply load and conceal real defects.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot the most common errors

“Executable doesn’t exist” or browser launch failure

The package is installed but its binaries are not. Run the matching playwright install command in the runtime image. On Linux, include system dependencies or use a maintained Playwright container.

Missing shared libraries

Minimal Linux images often lack fonts and graphics libraries. Install dependencies with npx playwright install --with-deps, use the documented container image, or select a runner image that already includes them.

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

Timeout waiting for a selector

Confirm the URL, authentication state, frame, and selector. Capture a failure screenshot and page HTML. Replace brittle CSS chains with role- or label-based locators where possible.

Works locally, fails in CI

Compare browser version, viewport, timezone, locale, network access, environment variables, and user data. CI may be slower or unable to reach an internal hostname. Print diagnostic versions without exposing secrets.

CDP connection closes unexpectedly

Check session expiry, idle limits, provider quotas, and whether the remote browser was terminated after an error. Reconnect only after creating a new session; do not reuse a closed endpoint.

Cloudflare Workers API mismatch

Review the Browser Run compatibility notes. The integration uses an adapted fork, so replace unsupported launch or filesystem calls with Workers-supported APIs rather than copying a desktop script unchanged.

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

Or skip the browser setup

If your goal is a clean website image or PDF rather than interactive test logic, ScreenshotNeo makes one request to capture a page. It accepts the cookie or consent banner like a visitor, removes more than 60 known consent platforms plus newsletter popups and chat widgets before capture, and bills only clean shots. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed; response headers identify the page verdict and billing result. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.

See the ScreenshotNeo API documentation for options such as full-page and element capture, device presets, custom CSS and JavaScript, waits, request blocking, headers and cookies, geolocation, PDF settings, caching, signed links, asynchronous jobs, bulk capture, and usage reporting.

cURL

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

Python

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)

Node.js

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

The Free plan includes 1,000 shots per month with no card. Paid plans start at $5 for 3,000 shots, and every feature is included on every plan. Create a free ScreenshotNeo account.

Cost, performance, and operational choices

CI cost is driven by runner minutes, parallelism, browser installation time, artifact storage, and any service used to host the browser. Caching dependencies can reduce setup time, but invalidate caches when Playwright versions change. Hosted browsers shift browser maintenance away from your runner but add session pricing and network latency. Workers can simplify deployment for Workers applications, while its adapted API requires a compatibility check.

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

For screenshots specifically, ScreenshotNeo’s billing headers let a caller distinguish a billed clean shot from a bot check, blank page, timeout, failed load, or cache hit. Its cache TTL, asynchronous jobs, webhooks, and bulk requests can reduce repeated work when those options fit your workflow.

Quick decision checklist

  • Choose CI when reproducibility and repository integration matter most.
  • Choose a hosted browser when you need a remotely managed session and your script fits the provider’s CDP support.
  • Choose Workers Browser Run when the application already lives on Cloudflare Workers and you can validate the adapted API.
  • Choose ScreenshotNeo when the deliverable is a clean screenshot or PDF and interactive Playwright control is unnecessary.

Frequently Asked Questions

Can I run Playwright without installing a browser locally?

Yes. Install Playwright and its browsers in a CI/container image, connect to a hosted browser over CDP, or use a compatible runtime such as Cloudflare Workers Browser Run.

Which browser engines does Playwright support?

Playwright supports Chromium, Firefox, and WebKit, subject to the engines exposed by your selected runtime or hosted service.

Do Playwright browser binaries update automatically with npm?

No. Install the binaries that match the Playwright package, and repeat browser installation after package upgrades.

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

Is a hosted browser the same as a screenshot API?

No. A hosted browser lets your Playwright code perform navigation and interaction. A screenshot API returns an image or PDF when that is all you need.

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 *

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

Read next

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

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.