
Understand Playwright's BrowserContexts and Pages
Playwright (and Puppeteer) exposes its API through Browser, BrowserContext, and Page objects with a blurry definition of their boundaries. This article covers their definition, how to leverage them, and how to avoid common pitfalls.

How to use BrowserContexts and Pages
The most common use cases benefiting from using multiple BrowserContexts or Pages are parallelization and cookie management.
Leverage BrowserContexts for parallelization
Crawling a large number of web pages sequentially can be slow. A common practice is to create multiple pages and visit them in parallel to speed up the automation:

Using multiple BrowserContext
is a good choice for parallelization as long as no authentication is involved.
However, remember that the overall performance of your automation’s parallelization will be limited by the underlying compute capacity assigned to the Browser.
Leverage Pages for cookie management
Pages
sharing the same storage and cookies are a good fit for getting granular control of the navigation and history.
For example, a first page can be created to complete an authentication flow. In contrast, other pages can later be created to navigate other parts of a website with their dedicated history.