BLOG
Do Browser Tasks: A Practical Guide to Remote Browsing
Learn what “do browser” can mean, how to automate browser tasks with Playwright and CDP, and when a hosted Chromium session fits your workflow.

If you searched for “do browser,” you may be looking for a way to make a browser perform a task: open a page, find information, submit a form, or check a workflow. You can do those tasks manually, with a local automation script, or through a browser session hosted remotely. The right choice depends on how often the task runs, what data it handles, and whether it needs to keep browser state between runs.
This guide explains how to do browser work with Playwright and Chrome DevTools Protocol (CDP), what a remote session changes, and which checks help keep an automated workflow reliable. It also covers when browser automation is a poor fit, such as when a stable API can provide the same data more directly.
What does “do browser” mean?
“Do browser” is an incomplete phrase, so the intended task matters. It might mean using a web browser yourself, asking software to operate a browser, or running an automated check against a website. In development, the latter two usually mean giving code or an agent access to a real browser and then telling it what to do.
A browser task can include:
- Opening a URL and waiting for a page to load.
- Finding a product or piece of information on a page.
- Filling and submitting a form.
- Checking that a page displays the expected content.
- Working through a site that depends on JavaScript or an existing login.
A browser can also hold state, including cookies, local storage, open tabs, and user preferences. That state can be useful for a multi-step workflow, but it needs to be handled deliberately. A script that shares a browser profile with unrelated jobs can expose one task’s data to another.
Before automating a task, describe its expected result in observable terms. “Search the account page and return the current plan name” is easier to verify than “use the website.” For actions that change data, define what counts as success and whether the task is allowed to submit the change.
Choose where the browser should run
A local browser is a good starting point for development. It is easy to inspect, and you can use the same machine to run the script and view the page. The trade-off is that the machine must be available and configured whenever the task runs.
A hosted Chromium session runs on remote infrastructure. Your application connects to it and sends browser commands over a supported interface such as CDP. This can make it easier to run jobs from a server or worker without installing and maintaining a browser on each machine. It also means you need to consider network latency, session lifecycle, authentication, and the provider’s usage limits.
| Option | Fits well when | Considerations |
|---|---|---|
| Manual browsing | A person needs to review or complete an occasional task | Requires a person to be available; steps may vary between runs |
| Local automation | You are developing or running jobs on a controlled machine | Your environment must install and maintain a compatible browser |
| Hosted browser session | Jobs run from remote workers or need a managed browser environment | Requires a network connection, session management, and attention to usage limits |
| Website API | The site offers an API with the data or action you need | May not expose the same workflow or content as the website |
A hosted browser is not automatically more reliable than a local one. Reliability depends on the page, network, selectors, browser configuration, and how your script handles errors. For a task that runs once on a developer’s laptop, local Playwright may be enough. For scheduled jobs or browser work shared across services, a remote runtime can reduce the work of operating browser processes.
For more background, see remote browsers for AI agents and remote browser online.
Connect Playwright to a remote browser with CDP
Playwright can connect to a Chromium browser over CDP with connectOverCDP. The hosted browser provider supplies the connection endpoint when a session is created. Keep that endpoint in a secret store or environment variable; it can grant access to the browser session.
The example below assumes you already have an active Chromium session and its CDP WebSocket endpoint. It opens a page, checks for a visible result, and reports failure if the expected content is missing.
import { chromium } from "playwright";
const endpoint = process.env.REMOTE_BROWSER_CDP_URL;
if (!endpoint) {
throw new Error("Set REMOTE_BROWSER_CDP_URL to the active session endpoint.");
}
const browser = await chromium.connectOverCDP(endpoint);
try {
const context = browser.contexts()[0] ?? await browser.newContext();
const page = context.pages()[0] ?? await context.newPage();
await page.goto("https://example.com", {
waitUntil: "domcontentloaded",
timeout: 30_000,
});
const heading = page.getByRole("heading", { name: "Example Domain" });
await heading.waitFor({ state: "visible", timeout: 10_000 });
console.log(await heading.innerText());
} finally {
await browser.close();
}The connectOverCDP method is for Chromium based browsers. See the Playwright CDP connection documentation for the API and its limitations.
Check your provider’s session lifecycle instructions before using this pattern in a scheduled job. A client disconnect and a remote session shutdown may be separate operations. If the provider exposes a session stop operation, call it when the task is complete so the browser does not continue running unnecessarily. A persistent profile may also outlive a session, so decide whether that profile should be reused or cleared for each workflow.
The sample uses a heading locator because it checks what the page rendered rather than assuming that navigation alone means the task succeeded. For a form submission, verify a confirmation message or resulting record. For a read task, validate the extracted value before passing it to another system.
Make browser tasks verifiable
Web pages change. A script that depends on a button’s position or a fixed delay can fail when the layout or loading time changes. Prefer locators tied to accessible roles and labels, and wait for a meaningful page condition before continuing.
For each task, make these decisions explicit:
- Starting state: Which URL, profile, and account should the session use?
- Allowed actions: Can the task read, edit, submit, or delete information?
- Success signal: What visible result or page state confirms completion?
- Failure behavior: Should the job retry, stop, or ask for human review?
- Output format: Which fields should the task return, and how should missing values be represented?
Retries need care. Repeating a read operation is usually less consequential than repeating a purchase, message, or form submission. Before retrying a state changing action, check whether the first attempt already succeeded. Otherwise, a timeout after submission could lead to the same action being submitted twice.
A useful browser workflow separates navigation, action, and verification. For example, a job might navigate to a record, confirm the record identifier, edit one field, submit the form, and then check that the new value appears. Logging the task identifier, URL, elapsed time, and outcome makes failures easier to investigate. Avoid logging passwords, session tokens, or page content that contains sensitive information.
Decide how to handle profiles and isolation
Persistent profiles can preserve sign-in state between sessions, which can help with workflows that require an authenticated account. They also preserve browser data, so profile access should be limited to the jobs that need it. Use separate profiles for unrelated accounts or tasks, and avoid sending profile data to logs or application output.
Session isolation matters when multiple jobs run at once. Each job should have a clear browser session and an explicit relationship to its profile. If two jobs share the same profile, they may also interact with the same cookies, tabs, or account state. That can cause unexpected actions or make results difficult to reproduce.
A practical setup typically defines:
- Which service or worker can create sessions.
- Which jobs can access each profile.
- How long sessions remain active.
- How the job signals that it has finished.
- What happens to session state after errors or worker restarts.
Remote Browser provides hosted Chromium sessions, CDP access, compatibility with Playwright, Puppeteer, and Selenium, a live viewer, persistent profiles, session isolation, and usage controls. The available browser settings and session behavior depend on configuration. Review the documentation for setup details and pricing for current limits and charges.
Know when browser automation is the wrong tool
A browser is useful when the workflow depends on the website’s actual interface or client-side behavior. It is often unnecessary when the site provides a documented API that returns the same data or performs the same action. An API can be easier to validate and less sensitive to layout changes.
Browser automation can also be a poor fit when a task requires a human judgment that is hard to encode, or when a site’s terms and access controls do not permit automation. Check the relevant site policies and use only the account access and data needed for the task.
Before moving a local task to a hosted browser, compare the practical costs:
- How many sessions will run, and for how long?
- Does the workflow need a saved login or a clean profile?
- Can a worker reach the browser endpoint securely?
- Does the task require a live view for debugging?
- What is the plan for session cleanup and failed jobs?
The remote web browser guide explains the runtime model in more detail. If the key requirement is sending commands to a remote browser, see remote control browser.
A production checklist for doing browser work
Before running browser tasks unattended, confirm that the workflow has a defined start state, observable success criteria, and a safe failure path. Then verify it with the same kind of session and profile the production job will use.
- Use stable locators. Prefer roles, labels, and text with clear meaning over screen coordinates or fragile selectors.
- Wait for page conditions. Wait for a result, state change, or visible element rather than relying on a fixed sleep.
- Verify consequential actions. Check that a submitted change took effect before reporting success.
- Protect session access. Treat CDP endpoints and saved profiles as sensitive credentials.
- Limit profile sharing. Keep unrelated accounts and jobs isolated.
- Plan cleanup. Define how sessions end after success, failure, or worker interruption.
- Track usage. Monitor session duration and concurrency against current account limits.
The phrase “do browser” can describe anything from opening a page to running an end-to-end workflow. Start by defining the specific task and its success condition. Use a local browser for simple development work, an API when it exposes the required operation, and a hosted Chromium session when a remote job needs a real browser. Then make the workflow observable, protect its state, and verify what happened before treating the task as complete.