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: hint that popup main request is accessible through BrowserContext (#30249)
Dmitry Gozman88f2717e8779
diff --git a/docs/src/api/class-browsercontext.md b/docs/src/api/class-browsercontext.mdindex 58205d170a..8dde2c031b 100644--- a/docs/src/api/class-browsercontext.md+++ b/docs/src/api/class-browsercontext.md@@ -218,7 +218,7 @@ also fire for popup pages. See also [`event: Page.popup`] to receive events abouThe earliest moment that page is available is when it has navigated to the initial url. For example, when opening apopup with `window.open('http://example.com')`, this event will fire when the network request to "http://example.com" is-done and its response has started loading in the popup.+done and its response has started loading in the popup. If you would like to route/listen to this network request, use [`method: BrowserContext.route`] and [`event: BrowserContext.request`] respectively instead of similar methods on the [Page].```jsconst newPagePromise = context.waitForEvent('page');diff --git a/docs/src/api/class-page.md b/docs/src/api/class-page.mdindex fdc3fa165a..6f388dda3f 100644--- a/docs/src/api/class-page.md+++ b/docs/src/api/class-page.md@@ -448,7 +448,7 @@ Emitted when the page opens a new tab or window. This event is emitted in additiThe earliest moment that page is available is when it has navigated to the initial url. For example, when opening apopup with `window.open('http://example.com')`, this event will fire when the network request to "http://example.com" is-done and its response has started loading in the popup.+done and its response has started loading in the popup. If you would like to route/listen to this network request, use [`method: BrowserContext.route`] and [`event: BrowserContext.request`] respectively instead of similar methods on the [Page].```js// Start waiting for popup before clicking. Note no await.@@ -3411,6 +3411,10 @@ The handler will only be called for the first url if the response is a redirect.[`method: Page.route`] will not intercept requests intercepted by Service Worker. See [this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when using request interception by setting [`option: Browser.newContext.serviceWorkers`] to `'block'`.:::+:::note+[`method: Page.route`] will not intercept the first request of a popup page. Use [`method: BrowserContext.route`] instead.+:::+**Usage**An example of a naive handler that aborts all image requests:diff --git a/packages/playwright-core/types/types.d.ts b/packages/playwright-core/types/types.d.tsindex cd92c1894c..c351680c92 100644--- a/packages/playwright-core/types/types.d.ts+++ b/packages/playwright-core/types/types.d.ts@@ -1031,7 +1031,12 @@ export interface Page {** The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a* popup with `window.open('http://example.com')`, this event will fire when the network request to- * "http://example.com" is done and its response has started loading in the popup.+ * "http://example.com" is done and its response has started loading in the popup. If you would like to route/listen+ * to this network request, use+ * [browserContext.route(url, handler[, options])](https://playwright.dev/docs/api/class-browsercontext#browser-context-route)+ * and+ * [browserContext.on('request')](https://playwright.dev/docs/api/class-browsercontext#browser-context-event-request)+ * respectively instead of similar methods on the {@link Page}.** ```js* // Start waiting for popup before clicking. Note no await.@@ -1326,7 +1331,12 @@ export interface Page {** The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a* popup with `window.open('http://example.com')`, this event will fire when the network request to- * "http://example.com" is done and its response has started loading in the popup.+ * "http://example.com" is done and its response has started loading in the popup. If you would like to route/listen+ * to this network request, use+ * [browserContext.route(url, handler[, options])](https://playwright.dev/docs/api/class-browsercontext#browser-context-route)+ * and+ * [browserContext.on('request')](https://playwright.dev/docs/api/class-browsercontext#browser-context-event-request)+ * respectively instead of similar methods on the {@link Page}.** ```js* // Start waiting for popup before clicking. Note no await.@@ -1716,7 +1726,12 @@ export interface Page {** The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a* popup with `window.open('http://example.com')`, this event will fire when the network request to- * "http://example.com" is done and its response has started loading in the popup.+ * "http://example.com" is done and its response has started loading in the popup. If you would like to route/listen+ * to this network request, use+ * [browserContext.route(url, handler[, options])](https://playwright.dev/docs/api/class-browsercontext#browser-context-route)+ * and+ * [browserContext.on('request')](https://playwright.dev/docs/api/class-browsercontext#browser-context-event-request)+ * respectively instead of similar methods on the {@link Page}.** ```js* // Start waiting for popup before clicking. Note no await.@@ -3658,6 +3673,11 @@ export interface Page {* issue. We recommend disabling Service Workers when using request interception by setting* `Browser.newContext.serviceWorkers` to `'block'`.*+ * **NOTE** [page.route(url, handler[, options])](https://playwright.dev/docs/api/class-page#page-route) will not+ * intercept the first request of a popup page. Use+ * [browserContext.route(url, handler[, options])](https://playwright.dev/docs/api/class-browsercontext#browser-context-route)+ * instead.+ ** **Usage**** An example of a naive handler that aborts all image requests:@@ -4504,7 +4524,12 @@ export interface Page {** The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a* popup with `window.open('http://example.com')`, this event will fire when the network request to- * "http://example.com" is done and its response has started loading in the popup.+ * "http://example.com" is done and its response has started loading in the popup. If you would like to route/listen+ * to this network request, use+ * [browserContext.route(url, handler[, options])](https://playwright.dev/docs/api/class-browsercontext#browser-context-route)+ * and+ * [browserContext.on('request')](https://playwright.dev/docs/api/class-browsercontext#browser-context-event-request)+ * respectively instead of similar methods on the {@link Page}.** ```js* // Start waiting for popup before clicking. Note no await.@@ -7745,7 +7770,12 @@ export interface BrowserContext {** The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a* popup with `window.open('http://example.com')`, this event will fire when the network request to- * "http://example.com" is done and its response has started loading in the popup.+ * "http://example.com" is done and its response has started loading in the popup. If you would like to route/listen+ * to this network request, use+ * [browserContext.route(url, handler[, options])](https://playwright.dev/docs/api/class-browsercontext#browser-context-route)+ * and+ * [browserContext.on('request')](https://playwright.dev/docs/api/class-browsercontext#browser-context-event-request)+ * respectively instead of similar methods on the {@link Page}.** ```js* const newPagePromise = context.waitForEvent('page');@@ -7936,7 +7966,12 @@ export interface BrowserContext {** The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a* popup with `window.open('http://example.com')`, this event will fire when the network request to- * "http://example.com" is done and its response has started loading in the popup.+ * "http://example.com" is done and its response has started loading in the popup. If you would like to route/listen+ * to this network request, use+ * [browserContext.route(url, handler[, options])](https://playwright.dev/docs/api/class-browsercontext#browser-context-route)+ * and+ * [browserContext.on('request')](https://playwright.dev/docs/api/class-browsercontext#browser-context-event-request)+ * respectively instead of similar methods on the {@link Page}.** ```js* const newPagePromise = context.waitForEvent('page');@@ -8182,7 +8217,12 @@ export interface BrowserContext {** The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a* popup with `window.open('http://example.com')`, this event will fire when the network request to- * "http://example.com" is done and its response has started loading in the popup.+ * "http://example.com" is done and its response has started loading in the popup. If you would like to route/listen+ * to this network request, use+ * [browserContext.route(url, handler[, options])](https://playwright.dev/docs/api/class-browsercontext#browser-context-route)+ * and+ * [browserContext.on('request')](https://playwright.dev/docs/api/class-browsercontext#browser-context-event-request)+ * respectively instead of similar methods on the {@link Page}.** ```js* const newPagePromise = context.waitForEvent('page');@@ -8827,7 +8867,12 @@ export interface BrowserContext {** The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a* popup with `window.open('http://example.com')`, this event will fire when the network request to- * "http://example.com" is done and its response has started loading in the popup.+ * "http://example.com" is done and its response has started loading in the popup. If you would like to route/listen+ * to this network request, use+ * [browserContext.route(url, handler[, options])](https://playwright.dev/docs/api/class-browsercontext#browser-context-route)+ * and+ * [browserContext.on('request')](https://playwright.dev/docs/api/class-browsercontext#browser-context-event-request)+ * respectively instead of similar methods on the {@link Page}.** ```js* const newPagePromise = context.waitForEvent('page');