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

This commit is contained in:
Max Schmitt 2025-07-10 13:57:06 +02:00 committed by GitHub
parent 5116bd414b
commit 5b9d836e97
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 0 deletions

View File

@ -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