Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

docs(route): add note about unroute (#6019)

Max Schmitt26f9e29623ef
diff --git a/docs/src/api/class-browsercontext.md b/docs/src/api/class-browsercontext.md
index 39cc80ace7..6136cfbb82 100644
--- a/docs/src/api/class-browsercontext.md
+++ b/docs/src/api/class-browsercontext.md
@@ -719,6 +719,8 @@ browser.close()
Page routes (set up with [`method: Page.route`]) take precedence over browser context routes when request matches both
handlers.
+To remove a route with its handler you can use [`method: BrowserContext.unroute`].
+
:::note
Enabling routing disables http cache.
:::
diff --git a/docs/src/api/class-page.md b/docs/src/api/class-page.md
index 83a6ca28f3..6750fe738b 100644
--- a/docs/src/api/class-page.md
+++ b/docs/src/api/class-page.md
@@ -2132,6 +2132,8 @@ browser.close()
Page routes take precedence over browser context routes (set up with [`method: BrowserContext.route`]) when request
matches both handlers.
+To remove a route with its handler you can use [`method: Page.unroute`].
+
:::note
Enabling routing disables http cache.
:::
diff --git a/types/types.d.ts b/types/types.d.ts
index db8af04356..0cea7d7f32 100644
--- a/types/types.d.ts
+++ b/types/types.d.ts
@@ -2351,6 +2351,9 @@ export interface Page {
* [browserContext.route(url, handler)](https://playwright.dev/docs/api/class-browsercontext#browsercontextrouteurl-handler))
* when request matches both handlers.
*
+ * To remove a route with its handler you can use
+ * [page.unroute(url[, handler])](https://playwright.dev/docs/api/class-page#pageunrouteurl-handler).
+ *
* > NOTE: Enabling routing disables http cache.
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while routing.
* @param handler handler function to route the request.
@@ -5012,6 +5015,9 @@ export interface BrowserContext {
* Page routes (set up with [page.route(url, handler)](https://playwright.dev/docs/api/class-page#pagerouteurl-handler))
* take precedence over browser context routes when request matches both handlers.
*
+ * To remove a route with its handler you can use
+ * [browserContext.unroute(url[, handler])](https://playwright.dev/docs/api/class-browsercontext#browsercontextunrouteurl-handler).
+ *
* > NOTE: Enabling routing disables http cache.
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while routing.
* @param handler handler function to route the request.