diff --git a/docs/src/release-notes-java.md b/docs/src/release-notes-java.md index a4443a1084..48192c303f 100644 --- a/docs/src/release-notes-java.md +++ b/docs/src/release-notes-java.md @@ -86,7 +86,7 @@ Note that the new methods [`method: Page.routeFromHAR`] and [`method: BrowserCon that only records information that is essential for replaying: ```java BrowserContext context = browser.newContext(new Browser.NewContextOptions() - .setRecordHarPath(Paths.get("example.har.zip")) + .setRecordHarPath(Paths.get("example.har")) .setRecordHarMode(HarMode.MINIMAL)); ``` * Playwright now runs on Ubuntu 22 amd64 and Ubuntu 22 arm64. We also publish new docker image `mcr.microsoft.com/playwright/java:v1.24.0-jammy`. diff --git a/docs/src/release-notes-js.md b/docs/src/release-notes-js.md index 7fa2f72bf6..87f16af2ae 100644 --- a/docs/src/release-notes-js.md +++ b/docs/src/release-notes-js.md @@ -96,12 +96,12 @@ Read more about [component testing with Playwright](./test-components). } }); ``` -* If you intend to edit HAR by hand, consider using the `"minimal"` HAR recording mode +* If you intend to edit HAR by hand, consider using the `"minimal"` HAR recording mode that only records information that is essential for replaying: ```ts const context = await browser.newContext({ recordHar: { - path: 'github.har.zip', + path: 'github.har', mode: 'minimal', } }); @@ -112,7 +112,7 @@ Read more about [component testing with Playwright](./test-components). WebServer is now considered "ready" if request to the specified port has any of the following HTTP status codes: -* `200-299` +* `200-299` * `300-399` (new) * `400`, `401`, `402`, `403` (new) diff --git a/docs/src/release-notes-python.md b/docs/src/release-notes-python.md index fe4072d1a5..5b20d240cc 100644 --- a/docs/src/release-notes-python.md +++ b/docs/src/release-notes-python.md @@ -5,6 +5,137 @@ title: "Release notes" +## Version 1.23 + +### Network Replay + +Now you can record network traffic into a HAR file and re-use this traffic in your tests. + +To record network into HAR file: + +```bash +npx playwright open --save-har=github.har.zip https://github.com/microsoft +``` + +Alternatively, you can record HAR programmatically: + +```python async +context = await browser.new_context(record_har_path="github.har.zip") +# ... do stuff ... +await context.close() +``` + +```python sync +context = browser.new_context(record_har_path="github.har.zip") +# ... do stuff ... +context.close() +``` + +Use the new methods [`method: Page.routeFromHAR`] or [`method: BrowserContext.routeFromHAR`] to serve matching responses from the [HAR](http://www.softwareishard.com/blog/har-12-spec/) file: + + +```python async +await context.route_from_har("github.har.zip") +``` + +```python sync +context.route_from_har("github.har.zip") +``` + +Read more in [our documentation](./network#record-and-replay-requests). + + +### Advanced Routing + +You can now use [`method: Route.fallback`] to defer routing to other handlers. + +Consider the following example: + +```python async +# Remove a header from all requests +async def remove_header_handler(route: Route) -> None: + headers = await route.request.all_headers() + if "if-none-match" in headers: + del headers["if-none-match"] + await route.fallback(headers=headers) + +await page.route("**/*", remove_header_handler) + +# Abort all images +async def abort_images_handler(route: Route) -> None: + if route.request.resource_type == "image": + await route.abort() + else: + await route.fallback() + +await page.route("**/*", abort_images_handler) +``` + +```python sync +# Remove a header from all requests +def remove_header_handler(route: Route) -> None: + headers = route.request.all_headers() + if "if-none-match" in headers: + del headers["if-none-match"] + route.fallback(headers=headers) + +page.route("**/*", remove_header_handler) + +# Abort all images +def abort_images_handler(route: Route) -> None: + if route.request.resource_type == "image": + route.abort() + else: + route.fallback() + +page.route("**/*", abort_images_handler) +``` + +Note that the new methods [`method: Page.routeFromHAR`] and [`method: BrowserContext.routeFromHAR`] also participate in routing and could be deferred to. + +### Web-First Assertions Update + +* New method [`method: LocatorAssertions.toHaveValues`] that asserts all selected values of `