---
title: "What Is Remote Browser Automation? CDP, WebDriver, Security"
description: "What is remote browser automation? A script controls a browser on another machine over CDP or WebDriver. Learn how to connect, keep logins and lock it down."
url: "https://donutbrowser.com/zh/remote-browser-automation/"
---

1. [首页](https://donutbrowser.com/zh/)

2. [博客](https://donutbrowser.com/zh/blog)

3. What Is Remote Browser Automation? CDP, WebDriver, Security

# What Is Remote Browser Automation? CDP, WebDriver, Security

November 25, 2026

remote browser automation cdp webdriver

**What is remote browser automation? It’s a setup where your script and the browser run on different machines or processes and talk over the Chrome DevTools Protocol (CDP) or W3C WebDriver. You pick a protocol and decide where the browser runs, then guard against the two common failures: an exposed debugging endpoint and sessions that can be linked to each other.**

Your script passed on your laptop, and now it has to run on a server, in a container or against a profile on another machine. This is for automation and QA engineers, agencies running client accounts and anyone wiring an AI agent to a browser.

By the end you’ll be able to attach to a remote browser, keep logins alive between runs, lock the endpoint down and choose where the browser lives. I make Donut Browser, which sells no proxies or hosting, so the trade-offs come without a pitch.

> **Key Takeaways**

> - [Playwright’s BrowserType docs](https://playwright.dev/docs/api/class-browsertype) say `connectOverCDP` is lower fidelity than its native `connect`, so choosing CDP has a cost.

> - Bind a CDP port to loopback or put authentication in front: anyone who reaches it controls the whole browser and profile.

> - [Remote MCP](https://donutbrowser.com/docs/remote-mcp) needs no inbound port: the desktop app keeps an outgoing connection.

## What is remote browser automation?

Remote browser automation is controlling a web browser from a script that runs on a different machine or process than the browser itself. The script sends commands over a protocol such as CDP or W3C WebDriver instead of launching the browser locally as a child process.

![Illustration for What Is Remote Browser Automation?](https://api.birchseek.com/m/wrRLgz4_Gy9aCuLMQwp0U3WMjp-eiVDI.webp)

The difference in remote browser automation is who starts the browser. With a **local launch**, your script starts the browser and the browser exits when the script does. With a **remote attach**, the browser is already running somewhere else and your script connects to it.

“Somewhere else” covers three cases:

- **A cloud service** that hosts browsers for you.

- **A server or container you run**, such as a Docker image in CI.

- **A profile on your own machine** listening on a loopback port like `127.0.0.1:9222`.

The third case still counts as remote browser automation because the script and the browser are separate processes, and they’re talking over a protocol.

Two protocols do the talking.

The [W3C WebDriver specification](https://www.w3.org/TR/webdriver/) calls WebDriver “a remote control interface that enables introspection and control of user agents.”

You can see an attach point yourself. Start Chrome with `--remote-debugging-port=9222`, then open `http://127.0.0.1:9222/json/version`. The JSON includes a `webSocketDebuggerUrl`, and that address is what a remote client connects to.

Teams move browsers off the laptop for three practical reasons. Servers and CI have no display, parallel runs need isolated profiles, and sometimes a person or an agent has to watch the session or take over.

## CDP vs WebDriver: how do you connect to a remote browser?

You connect to a remote browser either over CDP, which Playwright’s `connectOverCDP` uses, or over W3C WebDriver, which Selenium’s `Remote` class uses.

|  | Playwright `connectOverCDP` | Selenium `webdriver.Remote` |
| --- | --- | --- |
| Protocol | CDP | W3C WebDriver |
| Endpoint | `http://` or `ws://` URL of a running browser | Grid or remote driver URL |
| Browsers | Chromium-based only | Any browser with a WebDriver |
| Gives up | Fidelity, cross-browser reach | Low-level browser internals |

Playwright’s [browserType documentation](https://playwright.dev/docs/api/class-browsertype) says `connectOverCDP` “attaches Playwright to an existing browser instance using the Chrome DevTools Protocol.” You point it at a running browser’s endpoint and reuse the context that browser already has:

```
import { chromium } from 'playwright';

const browser = await chromium.connectOverCDP('http://127.0.0.1:9222');
const context = browser.contexts()[0];
const page = context.pages()[0] ?? await context.newPage();
```

The same page documents the cost. It says CDP connections are only supported for Chromium-based browsers, and that the connection is “significantly lower fidelity than the Playwright protocol connection via browserType.connect().”

If you hit problems, the docs point you to `connect`, which needs a Playwright server on the other end.

Selenium takes the standards route. Selenium’s [Grid documentation](https://www.selenium.dev/documentation/grid/) says Grid runs WebDriver scripts “on remote machines by routing commands sent by the client to remote browser instances.”

```
from selenium import webdriver

options = webdriver.ChromeOptions()
driver = webdriver.Remote(
    command_executor="http://grid.example.com:4444",
    options=options,
)
```

WebDriver works across browsers but exposes fewer browser internals.

If your remote browser is a persistent profile rather than a clean worker, the [browser automation use case](https://donutbrowser.com/use-cases/automation/) covers driving profiles over CDP.

**Best for CDP:** a Chromium browser you already run, where you need DevTools-level features and can accept lower fidelity.

**Best for WebDriver:** a Grid that serves several browsers, or a team that wants a standard protocol over deep browser access.

## How do you keep logins alive across remote browser runs?

You keep a login alive across remote runs by saving the browser’s cookies and local storage somewhere outside the disposable worker, then restoring them when the next run starts. A [practical guide to remote browser automation](https://remote-browser.dev/blog/remote-browser-automation) lists “session persistence, authentication state” among the constraints you face once the browser leaves your machine.

You have three ways to do it:

- **Reuse a long-lived remote browser.** Everything stays in that one browser. If it restarts, or two jobs share it, you lose the login or mix up accounts.

- **Restore a profile directory.** Playwright’s [`launchPersistentContext`](https://playwright.dev/docs/api/class-browsertype) starts a browser that uses persistent storage in a `userDataDir`. It keeps the whole profile, including cache and extensions, so it’s large. Two runs writing to one directory can corrupt it.

- **Save and load storage state.** Playwright’s [`storageState`](https://playwright.dev/docs/api/class-browsercontext) returns a snapshot of the current cookies and local storage. The file is small, but it holds only those two things.

For most teams the third option is the simplest to run:

1. **Log in once** by hand or in a headed run, and finish any two-factor prompt.

2. **Save the state** with `context.storageState({ path: "state.json" })` and move the file to encrypted storage.

3. **Restore it** by passing the file as `storageState` when you create each new context.

4. **Check the login** before acting. Load a page that only signed-in users see and confirm a known element is present.

5. **Re-authenticate on failure.** If the check fails, log in again, save a fresh state and retry once. Retrying in a loop can lock the account.

Sites expire sessions on their own schedule, so a saved state won’t work forever. Build step 5 in from the start.

Treat the file as a password. [Playwright’s authentication guide](https://playwright.dev/docs/auth) warns that the state file “may contain sensitive cookies and headers that could be used to impersonate you or your test account.” Keep it out of repositories and give each account its own file.

If you would rather not script the warm-up, [Donut Browser’s Solo plan](https://donutbrowser.com/pricing) includes a nightly Cookie Bot that warms enrolled profiles on a remote machine. It needs profiles without end-to-end encryption.

## How do AI agents drive a remote browser?

An AI agent drives a remote browser by calling browser actions as tools over the Model Context Protocol (MCP), which [its own site](https://modelcontextprotocol.io) calls an “open-source standard for connecting AI applications to external systems.” A server lists the actions it offers, and the agent’s client calls them.

For a browser, those tools are plain verbs: navigate, click, type, take a screenshot. The server runs each one in a real browser and sends the result back.

Remote MCP is the current agent route in Donut Browser, and the old local MCP server was removed. The desktop app keeps an outgoing connection to Donut cloud. Your MCP client calls `https://api.donutbrowser.com/api/mcp`, and the desktop answers, as the [remote MCP setup docs](https://donutbrowser.com/docs/remote-mcp/) describe.

In practice, you point Claude Code or Cursor at that URL. The agent works in a profile until it reaches a step it shouldn’t guess, such as a login prompt. It then asks you a question or asks for help inside the profile, and you step in. The Agent page shows what each connected agent is doing.

Plans decide which tools you get, per [Donut Browser’s pricing](https://donutbrowser.com/pricing):

- **Solo:** remote MCP for profiles, groups, proxies, VPNs, extensions and human-in-the-loop tools.

- **Pro, Team and Enterprise:** the same, plus browser control (launch, navigate, click, type, scroll, screenshot, evaluate) and recipes.

A recipe is a flow you record once and an agent repeats on other profiles without spending model tokens.

Keep a person in the approval path for payments and account changes. An agent can misread a page, and those actions are hard to reverse. Don’t skip that check.

## How do you secure remote browser automation?

You secure remote browser automation by treating the debugging port as a remote control for a logged-in browser: limit who can reach it, make them prove who they are, and limit what the profile holds if someone connects anyway.

Anyone who connects to a CDP endpoint can read pages, click, type and run JavaScript, and the port has no login of its own. The profile behind it usually holds cookies, local storage, saved passwords, extensions and tokens, which together amount to a logged-in user.

1. **Bind to loopback.** Keep the port on `127.0.0.1` so only processes on that machine can connect. [Donut Browser’s local REST API](https://donutbrowser.com/docs/rest-api) follows the same rule and listens on `127.0.0.1:10108`.

2. **Give the browser its own data directory.** [Chrome for Developers](https://developer.chrome.com/blog/remote-debugging-port) says the debugging switches “will no longer be respected if they are used to debug the default Chrome data directory”, so pass a separate `--user-data-dir`.

3. **Tunnel instead of opening a public port.** To reach a remote machine, forward the port over SSH, for example `ssh -L 9222:127.0.0.1:9222 user@host`. The browser stays on loopback and SSH handles authentication.

4. **Put authentication or an allow-list in front of any gateway.** If a proxy must expose the endpoint, require a token or restrict it to known IP addresses. An open WebSocket URL gives full control to whoever finds it.

5. **Use Selenium Grid’s own access controls.** Read the Selenium Grid documentation on securing a Grid and apply it before the Grid is reachable from outside your network.

6. **Run one isolated profile per task.** A worker that only needs one account shouldn’t share a profile with others, so a leaked connection exposes one login instead of all of them.

7. **Delete or encrypt saved state.** Cookie and storage dumps are credentials. Remove them when a run ends, or store them encrypted.

For AI agents, remote MCP removes the open port. In [Donut Browser’s remote MCP setup](https://donutbrowser.com/docs/remote-mcp/), the MCP client calls one cloud URL (`https://api.donutbrowser.com/api/mcp`) while the desktop app keeps an outgoing connection, so no inbound port opens on your machine.

[Donut Browser](https://donutbrowser.com) also keeps profile data local and has zero telemetry, which means no tracking or analytics requests leave the app.

## Local vs hosted vs self-hosted remote browsers: which fits?

A local browser fits development and a handful of identities, a hosted browser fits bursty scale when you don’t want to run servers, and a self-hosted one fits teams that need data control and accept the upkeep.

| Setup | Cost | Latency | Control | Maintenance |
| --- | --- | --- | --- | --- |
| Local (loopback attach) | Your own hardware | Lowest, same machine | Full | You update and restart it |
| Hosted cloud browser | Billed by the provider | Depends on distance to the provider | What the provider exposes | Provider runs it |
| Self-hosted remote (your own server or Grid) | Your own hardware and time | Low if near your scripts | Full | You patch, scale and secure it |

Every CDP command crosses the network between the script and the browser. Distance matters most for chatty scripts that send many small commands (click, read, click again). A script that opens one page and takes one screenshot barely notices it.

Selenium documents Grid as the self-hosted route. [Selenium Grid](https://www.selenium.dev/documentation/grid/) works by “routing commands sent by the client to remote browser instances.” You own the hardware, the patching and who can reach it.

Donut Browser sits in the local row, with the browser and its profile data on your machine.

Driving a profile over CDP with Playwright, Puppeteer or Selenium requires Pro, and Pro costs $99/month. Profile management through the [local REST API](https://donutbrowser.com/docs/rest-api) works on every plan, but launch, kill, open-url and batch run/stop return HTTP 402 without an active Pro subscription.

## How do you keep each remote session from being linked?

A remote browser stays unlinked when each session presents one consistent identity: an IP, a fingerprint and a timezone that agree with each other and differ from every other session. A browser in a cloud datacenter starts at a disadvantage, because its network and device signals tell a story before your script does anything.

Three signals give sessions away:

- **IP address.** Datacenter ranges are easy to recognize, and one shared IP ties sessions together. Give each identity its own proxy; the guide to [proxies for anti-detect browsers](https://donutbrowser.com/proxies-for-anti-detect-browsers/) compares residential, datacenter and mobile types.

- **Fingerprint.** A default fingerprint repeats across sessions and links them. [Browser fingerprinting](https://donutbrowser.com/browser-fingerprinting/) covers the signals involved, such as canvas, WebGL and audio.

- **Timezone.** A New York IP with an `Asia/Ho_Chi_Minh` timezone is a contradiction. Matching only the UTC offset isn’t enough, because the browser exposes a named zone: a Berlin proxy with a Prague timezone is still a mismatch.

For agencies, regional stores and QA teams, use one profile, one proxy, one fingerprint and one cookie store per identity.

Isolation doesn’t guarantee that accounts are never banned. Behavior and platform rules still apply.

Before you automate anything, open the profile and compare what it reports. Check the IP and timezone with a [free IP lookup](https://donutbrowser.com/tools/what-is-my-ip/), then run a fingerprint tool and confirm both tell the same story.

### Where Donut Browser fits

Donut Browser is open source under [AGPL-3.0](https://github.com/zhom/donutbrowser) and local-first. It doesn’t sell proxies, so you bring your own proxy or WireGuard config.

Each profile has its own fingerprint, cookies and proxy. Fingerprint spoofing is set inside the Chromium-based [Wayfern engine](https://donutbrowser.com/docs/wayfern) at the C++ level, so CDP tools see the same values.

The [free plan](https://donutbrowser.com/pricing) includes unlimited local profiles but no CDP automation. Pro adds the Browser Manipulation API.

[Try a profile in Donut Browser](https://donutbrowser.com) and run the IP and timezone check first.

## Frequently asked questions

### Is remote browser automation the same as headless?

**No: headless means a browser runs without a visible window, while remote means the script and the browser are on different machines or processes.** Chrome’s flag for it is `--headless`. A remote browser can be headless or headed, and a local browser can be headless too, so the two settings are independent.

### Is it safe to expose a CDP port to the internet?

**No, because anyone who reaches the port controls the whole browser and its logged-in profile.** Bind it to `127.0.0.1`, reach it through an SSH or VPN tunnel, or put a proxy that checks credentials in front of it.

### Can I drive a Donut Browser profile with Playwright on the free plan?

**No, attaching Playwright, Puppeteer or Selenium over CDP needs the [Pro plan](https://donutbrowser.com/pricing).** Profile management through the local REST API works on every plan, but [the launch and drive endpoints](https://donutbrowser.com/docs/rest-api) return HTTP 402 without an active Pro subscription.

### Will a remote browser stop my accounts from being banned?

**No, it removes technical linking signals such as a shared fingerprint, shared cookies or a shared IP.** Behavior and platform rules still apply, so an isolated profile that breaks a platform’s rules can still be banned.

## What to do next with remote browser automation

Start with one loopback attach on your own machine, then add session state and identity checks, then decide where the browser should run.

- **Today:** Start a browser on a loopback debugging port (`127.0.0.1:9222`) with a non-default user data directory. Attach with `connectOverCDP` or Selenium Remote and load one page.

- **This week:** Save session state after login and restore it at the start of each run. For every session, check that the IP, timezone and fingerprint agree.

- **Later:** Choose local, hosted or self-hosted by weighing cost, latency, control and maintenance. If an AI agent will drive the browser, add remote MCP.

To try this on isolated profiles, download Donut Browser. Local profiles are free and need no account.

## Sources

[BrowserType | Playwright](https://playwright.dev/docs/api/class-browsertype) · [Remote MCP · Docs — Donut Browser](https://donutbrowser.com/docs/remote-mcp) · [WebDriver, W3C Recommendation](https://www.w3.org/TR/webdriver/) · [Selenium Grid | Selenium](https://www.selenium.dev/documentation/grid/) · [Remote Browser Automation: A Practical Guide for Production](https://remote-browser.dev/blog/remote-browser-automation) · [BrowserContext | Playwright](https://playwright.dev/docs/api/class-browsercontext) · [Pricing | Donut Browser](https://donutbrowser.com/pricing) · [REST API · Docs — Donut Browser](https://donutbrowser.com/docs/rest-api). Every other source is linked where the article cites it.

## 在 Google 中更常看到我们

只需点击一次，即可在您的 Google 账号中将 Donut Browser 设为首选来源，我们的文章将更有可能出现在您的热门新闻、AI 模式和 AI 概览中。

在 Google 中设为首选来源

## On this page

- What is remote browser automation?

- CDP vs WebDriver: how do you connect to a remote browser?

- How do you keep logins alive across remote browser runs?

- How do AI agents drive a remote browser?

- How do you secure remote browser automation?

- Local vs hosted vs self-hosted remote browsers: which fits?

- How do you keep each remote session from being linked?

- Where Donut Browser fits

- Frequently asked questions

- Is remote browser automation the same as headless?

- Is it safe to expose a CDP port to the internet?

- Can I drive a Donut Browser profile with Playwright on the free plan?

- Will a remote browser stop my accounts from being banned?

- What to do next with remote browser automation

- Sources
