Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion docs/src/api/class-browsercontext.md
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,14 @@ Enabling routing disables http cache.

### param: BrowserContext.route.url
* since: v1.8
* langs: js
- `url` <[string]|[RegExp]|[URLPattern]|[function]\([URL]\):[boolean]>

A glob pattern, regex pattern, URL pattern, or predicate that receives a [URL] to match during routing. If [`option: Browser.newContext.baseURL`] is set in the context options and the provided URL is a string that does not start with `*`, it is resolved using the [`new URL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL) constructor.

### param: BrowserContext.route.url
* since: v1.8
* langs: python, csharp, java
- `url` <[string]|[RegExp]|[function]\([URL]\):[boolean]>

A glob pattern, regex pattern, or predicate that receives a [URL] to match during routing. If [`option: Browser.newContext.baseURL`] is set in the context options and the provided URL is a string that does not start with `*`, it is resolved using the [`new URL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL) constructor.
Expand Down Expand Up @@ -1560,9 +1568,18 @@ routes for the [`param: url`].

### param: BrowserContext.unroute.url
* since: v1.8
* langs: js
- `url` <[string]|[RegExp]|[URLPattern]|[function]\([URL]\):[boolean]>

A glob pattern, regex pattern, URL pattern, or predicate receiving [URL] used to register a routing with
[`method: BrowserContext.route`].

### param: BrowserContext.unroute.url
* since: v1.8
* langs: python, csharp, java
- `url` <[string]|[RegExp]|[function]\([URL]\):[boolean]>

A glob pattern, regex pattern or predicate receiving [URL] used to register a routing with
A glob pattern, regex pattern, or predicate receiving [URL] used to register a routing with
[`method: BrowserContext.route`].

### param: BrowserContext.unroute.handler
Expand Down
10 changes: 8 additions & 2 deletions docs/src/api/class-frame.md
Original file line number Diff line number Diff line change
Expand Up @@ -2077,7 +2077,10 @@ a navigation.
### param: Frame.waitForNavigation.action = %%-csharp-wait-for-event-action-%%
* since: v1.12

### option: Frame.waitForNavigation.url = %%-wait-for-navigation-url-%%
### option: Frame.waitForNavigation.url = %%-js-wait-for-navigation-url-%%
* since: v1.8

### option: Frame.waitForNavigation.url = %%-python-csharp-java-wait-for-navigation-url-%%
* since: v1.8

### option: Frame.waitForNavigation.waitUntil = %%-navigation-wait-until-%%
Expand Down Expand Up @@ -2273,7 +2276,10 @@ await frame.ClickAsync("a.delayed-navigation"); // clicking the link will indire
await frame.WaitForURLAsync("**/target.html");
```

### param: Frame.waitForURL.url = %%-wait-for-navigation-url-%%
### param: Frame.waitForURL.url = %%-js-wait-for-navigation-url-%%
* since: v1.11

### param: Frame.waitForURL.url = %%-python-csharp-java-wait-for-navigation-url-%%
* since: v1.11

### option: Frame.waitForURL.timeout = %%-navigation-timeout-%%
Expand Down
38 changes: 34 additions & 4 deletions docs/src/api/class-page.md
Original file line number Diff line number Diff line change
Expand Up @@ -2170,7 +2170,7 @@ var frame = page.FrameByUrl(".*domain.*");
* langs: js
- `frameSelector` <[string]|[Object]>
- `name` ?<[string]> Frame name specified in the `iframe`'s `name` attribute. Optional.
- `url` ?<[string]|[RegExp]|[function]\([URL]\):[boolean]> A glob pattern, regex pattern or predicate receiving
- `url` ?<[string]|[RegExp]|[URLPattern]|[function]\([URL]\):[boolean]> A glob pattern, regex pattern, URL pattern, or predicate receiving
frame's `url` as a [URL] object. Optional.

Frame name or other frame lookup options.
Expand Down Expand Up @@ -3684,6 +3684,14 @@ Enabling routing disables http cache.

### param: Page.route.url
* since: v1.8
* langs: js
- `url` <[string]|[RegExp]|[URLPattern]|[function]\([URL]\):[boolean]>

A glob pattern, regex pattern, URL pattern, or predicate that receives a [URL] to match during routing. If [`option: Browser.newContext.baseURL`] is set in the context options and the provided URL is a string that does not start with `*`, it is resolved using the [`new URL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL) constructor.

### param: Page.route.url
* since: v1.8
* langs: python, csharp, java
- `url` <[string]|[RegExp]|[function]\([URL]\):[boolean]>

A glob pattern, regex pattern, or predicate that receives a [URL] to match during routing. If [`option: Browser.newContext.baseURL`] is set in the context options and the provided URL is a string that does not start with `*`, it is resolved using the [`new URL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL) constructor.
Expand Down Expand Up @@ -3816,6 +3824,14 @@ await page.RouteWebSocketAsync("/ws", ws => {

### param: Page.routeWebSocket.url
* since: v1.48
* langs: js
- `url` <[string]|[RegExp]|[URLPattern]|[function]\([URL]\):[boolean]>

Only WebSockets with the url matching this pattern will be routed. A string pattern can be relative to the [`option: Browser.newContext.baseURL`] context option.

### param: Page.routeWebSocket.url
* since: v1.48
* langs: python, csharp, java
- `url` <[string]|[RegExp]|[function]\([URL]\):[boolean]>

Only WebSockets with the url matching this pattern will be routed. A string pattern can be relative to the [`option: Browser.newContext.baseURL`] context option.
Expand Down Expand Up @@ -4341,9 +4357,17 @@ the [`param: url`].

### param: Page.unroute.url
* since: v1.8
* langs: js
- `url` <[string]|[RegExp]|[URLPattern]|[function]\([URL]\):[boolean]>

A glob pattern, regex pattern, URL pattern, or predicate receiving [URL] to match while routing.

### param: Page.unroute.url
* since: v1.8
* langs: python, csharp, java
- `url` <[string]|[RegExp]|[function]\([URL]\):[boolean]>

A glob pattern, regex pattern or predicate receiving [URL] to match while routing.
A glob pattern, regex pattern, or predicate receiving [URL] to match while routing.

### param: Page.unroute.handler
* since: v1.8
Expand Down Expand Up @@ -4840,7 +4864,10 @@ a navigation.
### param: Page.waitForNavigation.action = %%-csharp-wait-for-event-action-%%
* since: v1.12

### option: Page.waitForNavigation.url = %%-wait-for-navigation-url-%%
### option: Page.waitForNavigation.url = %%-js-wait-for-navigation-url-%%
* since: v1.8

### option: Page.waitForNavigation.url = %%-python-csharp-java-wait-for-navigation-url-%%
* since: v1.8

### option: Page.waitForNavigation.waitUntil = %%-navigation-wait-until-%%
Expand Down Expand Up @@ -5377,7 +5404,10 @@ await page.ClickAsync("a.delayed-navigation"); // clicking the link will indirec
await page.WaitForURLAsync("**/target.html");
```

### param: Page.waitForURL.url = %%-wait-for-navigation-url-%%
### param: Page.waitForURL.url = %%-js-wait-for-navigation-url-%%
* since: v1.11

### param: Page.waitForURL.url = %%-python-csharp-java-wait-for-navigation-url-%%
* since: v1.11

### option: Page.waitForURL.timeout = %%-navigation-timeout-%%
Expand Down
5 changes: 4 additions & 1 deletion docs/src/api/class-pageassertions.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,9 @@ await expect(page).toHaveURL('https://playwright.dev/docs/intro');
// Check for the page URL to contain 'doc', followed by an optional 's', followed by '/'
await expect(page).toHaveURL(/docs?\//);

// Check for the page URL to match the URL pattern
await expect(page).toHaveURL(new URLPattern({ pathname: '/docs/*' }));

// Check for the predicate to be satisfied
// For example: verify query strings
await expect(page).toHaveURL(url => {
Expand Down Expand Up @@ -337,7 +340,7 @@ await Expect(Page).ToHaveURLAsync(new Regex(".*checkout"));
### param: PageAssertions.toHaveURL.url
* since: v1.18
* langs: js
- `url` <[string]|[RegExp]|[function]\([URL]\):[boolean]>
- `url` <[string]|[RegExp]|[URLPattern]|[function]\([URL]\):[boolean]>

Expected URL string, RegExp, or predicate receiving [URL] to match.
When [`option: Browser.newContext.baseURL`] is provided via the context options and the `url` argument is a string, the two values are merged via the [`new URL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL) constructor and used for the comparison against the current browser URL.
Expand Down
13 changes: 11 additions & 2 deletions docs/src/api/params.md
Original file line number Diff line number Diff line change
Expand Up @@ -890,10 +890,19 @@ Options to select. If the `<select>` has the `multiple` attribute, all matching
first option matching one of the passed options is selected. String values are matching both values and labels. Option
is considered matching if all specified properties match.

## wait-for-navigation-url
## js-wait-for-navigation-url
* langs: js
- `url` <[string]|[RegExp]|[URLPattern]|[function]\([URL]\):[boolean]>

A glob pattern, regex pattern, URL pattern, or predicate receiving [URL] to match while waiting for the navigation. Note that if
the parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly
equal to the string.

## python-csharp-java-wait-for-navigation-url
* langs: python, csharp, java
- `url` <[string]|[RegExp]|[function]\([URL]\):[boolean]>

A glob pattern, regex pattern or predicate receiving [URL] to match while waiting for the navigation. Note that if
A glob pattern, regex pattern, or predicate receiving [URL] to match while waiting for the navigation. Note that if
the parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly
equal to the string.

Expand Down
58 changes: 31 additions & 27 deletions packages/playwright-client/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ import { ReadStream } from 'fs';
import { Protocol } from './protocol';
import { Serializable, EvaluationArgument, PageFunction, PageFunctionOn, SmartHandle, ElementHandleForTag, BindingSource } from './structs';

// Use the global URLPattern type if available (Node.js 22+, modern browsers),
// otherwise fall back to `never` so it disappears from union types.
type URLPattern = typeof globalThis extends { URLPattern: infer T } ? T : never;

type PageWaitForSelectorOptionsNotHidden = PageWaitForSelectorOptions & {
state?: 'visible'|'attached';
};
Expand Down Expand Up @@ -2840,9 +2844,9 @@ export interface Page {
name?: string;

/**
* A glob pattern, regex pattern or predicate receiving frame's `url` as a [URL] object. Optional.
* A glob pattern, regex pattern, URL pattern, or predicate receiving frame's `url` as a [URL] object. Optional.
*/
url?: string|RegExp|((url: URL) => boolean);
url?: string|RegExp|URLPattern|((url: URL) => boolean);
}): null|Frame;

/**
Expand Down Expand Up @@ -4097,14 +4101,14 @@ export interface Page {
*
* **NOTE** Enabling routing disables http cache.
*
* @param url A glob pattern, regex pattern, or predicate that receives a [URL] to match during routing. If
* @param url A glob pattern, regex pattern, URL pattern, or predicate that receives a [URL] to match during routing. If
* [`baseURL`](https://playwright.dev/docs/api/class-browser#browser-new-context-option-base-url) is set in the
* context options and the provided URL is a string that does not start with `*`, it is resolved using the
* [`new URL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL) constructor.
* @param handler handler function to route the request.
* @param options
*/
route(url: string|RegExp|((url: URL) => boolean), handler: ((route: Route, request: Request) => Promise<any>|any), options?: {
route(url: string|RegExp|URLPattern|((url: URL) => boolean), handler: ((route: Route, request: Request) => Promise<any>|any), options?: {
/**
* How often a route should be used. By default it will be used every time.
*/
Expand Down Expand Up @@ -4185,7 +4189,7 @@ export interface Page {
* [`baseURL`](https://playwright.dev/docs/api/class-browser#browser-new-context-option-base-url) context option.
* @param handler Handler function to route the WebSocket.
*/
routeWebSocket(url: string|RegExp|((url: URL) => boolean), handler: ((websocketroute: WebSocketRoute) => Promise<any>|any)): Promise<void>;
routeWebSocket(url: string|RegExp|URLPattern|((url: URL) => boolean), handler: ((websocketroute: WebSocketRoute) => Promise<any>|any)): Promise<void>;

/**
* Returns the buffer with the captured screenshot.
Expand Down Expand Up @@ -4776,10 +4780,10 @@ export interface Page {
* [page.route(url, handler[, options])](https://playwright.dev/docs/api/class-page#page-route). When
* [`handler`](https://playwright.dev/docs/api/class-page#page-unroute-option-handler) is not specified, removes all
* routes for the [`url`](https://playwright.dev/docs/api/class-page#page-unroute-option-url).
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while routing.
* @param url A glob pattern, regex pattern, URL pattern, or predicate receiving [URL] to match while routing.
* @param handler Optional handler function to route the request.
*/
unroute(url: string|RegExp|((url: URL) => boolean), handler?: ((route: Route, request: Request) => Promise<any>|any)): Promise<void>;
unroute(url: string|RegExp|URLPattern|((url: URL) => boolean), handler?: ((route: Route, request: Request) => Promise<any>|any)): Promise<void>;

/**
* Removes all routes created with
Expand Down Expand Up @@ -5111,11 +5115,11 @@ export interface Page {
timeout?: number;

/**
* A glob pattern, regex pattern or predicate receiving [URL] to match while waiting for the navigation. Note that if
* the parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly
* equal to the string.
* A glob pattern, regex pattern, URL pattern, or predicate receiving [URL] to match while waiting for the navigation.
* Note that if the parameter is a string without wildcard characters, the method will wait for navigation to URL that
* is exactly equal to the string.
*/
url?: string|RegExp|((url: URL) => boolean);
url?: string|RegExp|URLPattern|((url: URL) => boolean);

/**
* When to consider operation succeeded, defaults to `load`. Events can be either:
Expand Down Expand Up @@ -5229,12 +5233,12 @@ export interface Page {
* await page.waitForURL('**\/target.html');
* ```
*
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while waiting for the navigation. Note that if
* the parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly
* equal to the string.
* @param url A glob pattern, regex pattern, URL pattern, or predicate receiving [URL] to match while waiting for the navigation.
* Note that if the parameter is a string without wildcard characters, the method will wait for navigation to URL that
* is exactly equal to the string.
* @param options
*/
waitForURL(url: string|RegExp|((url: URL) => boolean), options?: {
waitForURL(url: string|RegExp|URLPattern|((url: URL) => boolean), options?: {
/**
* Maximum operation time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via
* `navigationTimeout` option in the config, or by using the
Expand Down Expand Up @@ -8294,11 +8298,11 @@ export interface Frame {
timeout?: number;

/**
* A glob pattern, regex pattern or predicate receiving [URL] to match while waiting for the navigation. Note that if
* the parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly
* equal to the string.
* A glob pattern, regex pattern, URL pattern, or predicate receiving [URL] to match while waiting for the navigation.
* Note that if the parameter is a string without wildcard characters, the method will wait for navigation to URL that
* is exactly equal to the string.
*/
url?: string|RegExp|((url: URL) => boolean);
url?: string|RegExp|URLPattern|((url: URL) => boolean);

/**
* When to consider operation succeeded, defaults to `load`. Events can be either:
Expand Down Expand Up @@ -8335,12 +8339,12 @@ export interface Frame {
* await frame.waitForURL('**\/target.html');
* ```
*
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while waiting for the navigation. Note that if
* the parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly
* equal to the string.
* @param url A glob pattern, regex pattern, URL pattern, or predicate receiving [URL] to match while waiting for the navigation.
* Note that if the parameter is a string without wildcard characters, the method will wait for navigation to URL that
* is exactly equal to the string.
* @param options
*/
waitForURL(url: string|RegExp|((url: URL) => boolean), options?: {
waitForURL(url: string|RegExp|URLPattern|((url: URL) => boolean), options?: {
/**
* Maximum operation time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via
* `navigationTimeout` option in the config, or by using the
Expand Down Expand Up @@ -9418,14 +9422,14 @@ export interface BrowserContext {
*
* **NOTE** Enabling routing disables http cache.
*
* @param url A glob pattern, regex pattern, or predicate that receives a [URL] to match during routing. If
* @param url A glob pattern, regex pattern, URL pattern, or predicate that receives a [URL] to match during routing. If
* [`baseURL`](https://playwright.dev/docs/api/class-browser#browser-new-context-option-base-url) is set in the
* context options and the provided URL is a string that does not start with `*`, it is resolved using the
* [`new URL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL) constructor.
* @param handler handler function to route the request.
* @param options
*/
route(url: string|RegExp|((url: URL) => boolean), handler: ((route: Route, request: Request) => Promise<any>|any), options?: {
route(url: string|RegExp|URLPattern|((url: URL) => boolean), handler: ((route: Route, request: Request) => Promise<any>|any), options?: {
/**
* How often a route should be used. By default it will be used every time.
*/
Expand Down Expand Up @@ -9738,12 +9742,12 @@ export interface BrowserContext {
* When [`handler`](https://playwright.dev/docs/api/class-browsercontext#browser-context-unroute-option-handler) is
* not specified, removes all routes for the
* [`url`](https://playwright.dev/docs/api/class-browsercontext#browser-context-unroute-option-url).
* @param url A glob pattern, regex pattern or predicate receiving [URL] used to register a routing with
* @param url A glob pattern, regex pattern, URL pattern, or predicate receiving [URL] used to register a routing with
* [browserContext.route(url, handler[, options])](https://playwright.dev/docs/api/class-browsercontext#browser-context-route).
* @param handler Optional handler function used to register a routing with
* [browserContext.route(url, handler[, options])](https://playwright.dev/docs/api/class-browsercontext#browser-context-route).
*/
unroute(url: string|RegExp|((url: URL) => boolean), handler?: ((route: Route, request: Request) => Promise<any>|any)): Promise<void>;
unroute(url: string|RegExp|URLPattern|((url: URL) => boolean), handler?: ((route: Route, request: Request) => Promise<any>|any)): Promise<void>;

/**
* Removes all routes created with
Expand Down
Loading
Loading