Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
docs: add response interception to network guide (#9598)
Yury Semikhatsky79955fc4a827
diff --git a/docs/src/network.md b/docs/src/network.mdindex ce81a18910..25fb2b4d34 100644--- a/docs/src/network.md+++ b/docs/src/network.md@@ -577,6 +577,44 @@ else<br/>+## Modify responses+* langs: js++To modify a response use [ApiRequestContext] to get original response and then pass the response to [`method: Route.fulfill`].+You can override individual fields on the reponse via options:++```js+await page.route('**/title.html', async route => {+ // Fetch original response.+ const response = await page.request.fetch(route.request());+ // Add a prefix to the title.+ let body = await response.text();+ body = body.replace('<title>', '<title>My prefix:');+ route.fulfill({+ // Pass all fields from the response.+ response,+ // Override response body.+ body,+ // Force content type to be html.+ headers: {+ ...response.headers(),+ 'content-type': 'text/html'+ }+ });+});+```++### API reference+- [ApiRequestContext]+- [`method: Page.route`]+- [`method: BrowserContext.route`]+- [`property: Playwright.request`]+- [`property: BrowserContext.request`]+- [`property: Page.request`]+- [`method: Route.fulfill`]++<br/>+## WebSocketsPlaywright supports [WebSockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API) inspection out of the