Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

docs: add note on recording HAR files with Browser.newContext (#36630)

Max Schmitt5b9d836e9790
diff --git a/docs/src/mock.md b/docs/src/mock.md
index 24385d3497..eab111fd3d 100644
--- a/docs/src/mock.md
+++ b/docs/src/mock.md
@@ -232,6 +232,16 @@ The options object can contain the URL so that only requests with the URL matchi
Setting `update` option to true will create or update the HAR file with the actual network information instead of serving the requests from the HAR file. Use it when creating a test to populate the HAR with real data.
+####
+* langs: js
+
+Alternatively, you can also record HAR files by using the [`option: Browser.newContext.recordHar`] option in [`method: Browser.newContext`] when creating a browser context. This allows you to capture all network traffic for the entire context until the context is closed.
+
+####
+* langs: csharp, java, python
+
+Alternatively, you can also record HAR files by using the [`option: Browser.newContext.recordHarPath`] option in [`method: Browser.newContext`] when creating a browser context. This allows you to capture all network traffic for the entire context until the context is closed.
+
```js
test('records or updates the HAR file', async ({ page }) => {
// Get the response from the HAR file