Playwright
Exploring the Depths of Playwright: Browser Contexts, Page, APIs and Workers
BrowserContext
BrowserContexts provide a way to operate multiple independent browser sessions.
Playwright allows creating "incognito" browser contexts with browser.newContext() method.
Page
Visualization
Usage
One Test, Many Contexts
APIRequestContext
This API is used for the Web API testing. You can use it to trigger API endpoints
Context request vs global request
Good for requests that need to share session data with the browser context
It's not tied to any particular page but inherits the context's configuration, such as user agent and any cookies or local storage data already set within the context. Updates cookies
1
context.request
Best for requests specifically associated with the activity or data of a particular page or headers specific to that page.
Updates cookies
2
page.request
Isolated instance, a standalone request outside of Playwright's page or context scope
Does not use or updates updates cookies from the browser context
3
request fixture
Usage
Workers
These processes are OS processes, running independently, orchestrated by the test runner.
All workers have identical environments and each starts its own browser.
Thank You!
Questions?
Palette
By TenantCloud
Palette
- 121