Skip to main content
Use one profiled browser when several tasks need the same browser identity at the same time. Give each task a named Playwright executor, so each task gets its own tab while tasks on different executors run concurrently. This guide is a concise overview of the full, runnable parallel profile Playwright executors cookbook, which this pattern is based on. This pattern is particularly useful when the browser must save changes to a profile. All task tabs share the browser’s cookies and persistent origin storage, and the browser writes the complete profile once when the run ends. If tasks only read profile state, you can use a separate read-only browser for each task instead; see Sharing and concurrency.

How it works

  1. Start one browser with the shared profile and save_changes: true. Use start_url when you want to replace a tab restored from an earlier run.
  2. Bound the number of active tasks. A browser supports up to eight named executors, and memory, CPU, site behavior, or model limits can become constraints.
  3. Assign each task an executor name such as lane-1 or lane-2. Send every Playwright call for each task to the same executor so its page remains bound to one tab.
  4. Keep each task’s work in its executor-owned tab. Browser state persists between calls, but local JavaScript variables do not.
  5. Delete an executor and close its tab before reusing its name for another task. Delete the browser after all tasks finish so the profile is saved.

Run tasks in parallel

Use Promise.all or asyncio.gather for concurrent tasks. A production worker pool can reuse a fixed set of executor names as tasks finish. The examples assume that the parallel-task-demo profile already exists.
One task failing doesn’t need to stop the other tasks, but the run must still clean up every executor and the browser. Publish task results as they finish when callers need progress before the full run completes. For the full cookbook—including bounded concurrency, lane reuse, result publishing, and fault-tolerant cleanup—see the parallel profile Playwright executors cookbook.