v1.48.0
microsoft/playwrightv1.48.0Oct 8, 2024by mxschmitt
AI Summary
Adds WebSocket routing capabilities and improves reporting features with copy buttons and network tab enhancements.
Key Highlights
- New page.routeWebSocket() and browserContext.routeWebSocket() methods
- New 'Copy as cURL' and 'Copy as fetch' buttons in network tab
- Route fulfill calls no longer shown in report/trace
- New page.requestGC() method for memory leak detection
- Detailed timing and security info in HAR
New Features
- WebSocket routing
- Copy buttons for annotations and test location
- FormData support for API requests
- Step location option
- Detailed HAR recording
Full Release Notes
## WebSocket routing
New methods [page.routeWebSocket()](https://playwright.dev/docs/api/class-page#page-route-web-socket) and [browserContext.routeWebSocket()](https://playwright.dev/docs/api/class-browsercontext#browser-context-route-web-socket) allow to intercept, modify and mock WebSocket connections initiated in the page. Below is a simple example that mocks WebSocket communication by responding to a `"request"` with a `"response"`.
```js
await page.routeWebSocket('/ws', ws => {
ws.onMessage(message => {
if (message === 'request')
ws.send('response');
});
});
```
See [WebSocketRoute](https://playwright.dev/docs/api/class-websocketroute) for more details.
## UI updates
- New "copy" buttons for annotations and test location in the HTML report.
- Route method calls like [route.fulfill()](https://playwright.dev/docs/api/class-route#route-fulfill) are not shown in the report and trace viewer anymore. You can see which network requests were routed in the network tab instead.
- New "Copy as cURL" and "Copy as fetch" buttons for requests in the network tab.
## Miscellaneous
- Option [`form`](https://playwright.dev/docs/api/class-apirequestcontext#api-request-context-fetch-option-form) and similar ones now accept [FormData](https://playwright.dev/docs/api/class-formdata).
- New method [page.requestGC()](https://playwright.dev/docs/api/class-page#page-request-gc) may help detect memory leaks.
- New option [`location`](https://playwright.dev/docs/api/class-test#test-step-option-location) to pass custom step location.
- Requests made by [APIRequestContext](https://playwright.dev/docs/api/class-apirequestcontext) now record detailed timing and security information in the HAR.
## Browser Versions
- Chromium 130.0.6723.19
- Mozilla Firefox 130.0
- WebKit 18.0
This version was also tested against the following stable channels:
- Google Chrome 129
- Microsoft Edge 129