chore: port 1.23 Python release notes (#15289)
This commit is contained in:
parent
268bfec4b9
commit
aced45347b
|
|
@ -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`.
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,137 @@ title: "Release notes"
|
|||
|
||||
<!-- TOC -->
|
||||
|
||||
## 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 `<select multiple>` element.
|
||||
* Methods [`method: LocatorAssertions.toContainText`] and [`method: LocatorAssertions.toHaveText`] now accept `ignore_case` option.
|
||||
|
||||
### Miscellaneous
|
||||
|
||||
* If there's a service worker that's in your way, you can now easily disable it with a new context option `service_workers`:
|
||||
|
||||
```python async
|
||||
context = await browser.new_context(service_workers="block")
|
||||
page = await context.new_page()
|
||||
```
|
||||
|
||||
```python sync
|
||||
context = browser.new_context(service_workers="block")
|
||||
page = context.new_page()
|
||||
```
|
||||
|
||||
* Using `.zip` path for `recordHar` context option automatically zips the resulting HAR:
|
||||
|
||||
```python async
|
||||
context = await browser.new_context(record_har_path="github.har.zip")
|
||||
```
|
||||
|
||||
```python sync
|
||||
context = browser.new_context(record_har_path="github.har.zip")
|
||||
```
|
||||
|
||||
* If you intend to edit HAR by hand, consider using the `"minimal"` HAR recording mode
|
||||
that only records information that is essential for replaying:
|
||||
|
||||
```python async
|
||||
context = await browser.new_context(record_har_mode="minimal", record_har_path="har.har")
|
||||
```
|
||||
|
||||
```python sync
|
||||
context = browser.new_context(record_har_mode="minimal", record_har_path="har.har")
|
||||
```
|
||||
|
||||
* Playwright now runs on Ubuntu 22 amd64 and Ubuntu 22 arm64. We also publish new docker image `mcr.microsoft.com/playwright/python:v1.24.0-jammy`.
|
||||
|
||||
|
||||
## Version 1.22
|
||||
|
||||
### Highlights
|
||||
|
|
|
|||
Loading…
Reference in New Issue