|
| 1 | +/// <reference lib="dom" /> |
| 2 | + |
1 | 3 | /** |
2 | 4 | * Represents event-specific properties. Refer to the events documentation for |
3 | 5 | * the lists of initial properties: |
|
12 | 14 | export type EvaluationArgument = object; |
13 | 15 |
|
14 | 16 | export type PageFunction<Arg, R> = string | ((arg: Unboxed<Arg>) => R); |
| 17 | +export type PageFunctionOn<On, Arg2, R> = string | ((on: On, arg2: Unboxed<Arg2>) => R); |
15 | 18 |
|
16 | 19 | export type Unboxed<Arg> = Arg extends [infer A0, infer A1] ? [Unboxed<A0>, Unboxed<A1>] |
17 | 20 | : Arg extends [infer A0, infer A1, infer A2] ? [Unboxed<A0>, Unboxed<A1>, Unboxed<A2>] |
@@ -2997,6 +3000,35 @@ export interface Locator { |
2997 | 3000 | */ |
2998 | 3001 | dblclick(options?: MouseMoveOptions & MouseMultiClickOptions): Promise<void>; |
2999 | 3002 |
|
| 3003 | + /** |
| 3004 | + * Evaluates the page function and returns its return value. |
| 3005 | + * This method passes this locator's matching element as the first argument to the page function. |
| 3006 | + * |
| 3007 | + * @param pageFunction Function to be evaluated in the page context. |
| 3008 | + * @param arg Optional argument to pass to `pageFunction`. |
| 3009 | + * @returns Return value of `pageFunction`. |
| 3010 | + */ |
| 3011 | + // eslint-disable-next-line @definitelytyped/no-unnecessary-generics |
| 3012 | + evaluate<R, E extends SVGElement | HTMLElement, Arg>( |
| 3013 | + pageFunction: PageFunctionOn<E, Arg, R>, |
| 3014 | + arg?: Arg, |
| 3015 | + ): Promise<R>; |
| 3016 | + |
| 3017 | + /** |
| 3018 | + * Evaluates the page function and returns its return value as a [JSHandle]. |
| 3019 | + * This method passes this locator's matching element as the first argument to the page function. |
| 3020 | + * Unlike `evaluate`, `evaluateHandle` returns the value as a `JSHandle` |
| 3021 | + * |
| 3022 | + * @param pageFunction Function to be evaluated in the page context. |
| 3023 | + * @param arg Optional argument to pass to `pageFunction`. |
| 3024 | + * @returns JSHandle of the return value of `pageFunction`. |
| 3025 | + */ |
| 3026 | + // eslint-disable-next-line @definitelytyped/no-unnecessary-generics |
| 3027 | + evaluateHandle<R, E extends SVGElement | HTMLElement, Arg>( |
| 3028 | + pageFunction: PageFunctionOn<E, Arg, R>, |
| 3029 | + arg?: Arg, |
| 3030 | + ): Promise<JSHandle<R>>; |
| 3031 | + |
3000 | 3032 | /** |
3001 | 3033 | * Use this method to select an `input type="checkbox"`. |
3002 | 3034 | * @param options Options to use. |
@@ -5424,6 +5456,16 @@ export interface Page { |
5424 | 5456 | }, |
5425 | 5457 | ): Promise<void>; |
5426 | 5458 |
|
| 5459 | + /** |
| 5460 | + * Removes all existing routes for the `url`. |
| 5461 | + */ |
| 5462 | + unroute(url: string | RegExp): Promise<void>; |
| 5463 | + |
| 5464 | + /** |
| 5465 | + * Removes all routes created with page.route(). |
| 5466 | + */ |
| 5467 | + unrouteAll(): Promise<void>; |
| 5468 | + |
5427 | 5469 | /** |
5428 | 5470 | * Returns the page's URL. |
5429 | 5471 | */ |
@@ -5621,6 +5663,36 @@ export interface Page { |
5621 | 5663 | }, |
5622 | 5664 | ): Promise<Response | null>; |
5623 | 5665 |
|
| 5666 | + /** |
| 5667 | + * Waits for the page to match against the URL for a Request object |
| 5668 | + * |
| 5669 | + * @example |
| 5670 | + * ```js |
| 5671 | + * const requestPromise = page.waitForRequest('https://example.com/resource'); |
| 5672 | + * await page.goto('https://example.com/resource'); |
| 5673 | + * const request = await requestPromise; |
| 5674 | + * ``` |
| 5675 | + * |
| 5676 | + * @param request Request URL string or regex to match against Request object. |
| 5677 | + * @param options Options to use. |
| 5678 | + */ |
| 5679 | + waitForRequest( |
| 5680 | + request: string | RegExp, |
| 5681 | + options?: { |
| 5682 | + /** |
| 5683 | + * Maximum operation time in milliseconds. Defaults to `30` seconds. |
| 5684 | + * The default value can be changed via the |
| 5685 | + * browserContext.setDefaultNavigationTimeout(timeout), |
| 5686 | + * browserContext.setDefaultTimeout(timeout), |
| 5687 | + * page.setDefaultNavigationTimeout(timeout) or |
| 5688 | + * page.setDefaultTimeout(timeout) methods. |
| 5689 | + * |
| 5690 | + * Setting the value to `0` will disable the timeout. |
| 5691 | + */ |
| 5692 | + timeout?: number; |
| 5693 | + }, |
| 5694 | + ): Promise<Request | null>; |
| 5695 | + |
5624 | 5696 | /** |
5625 | 5697 | * **NOTE** Use web assertions that assert visibility or a locator-based |
5626 | 5698 | * locator.waitFor([options]) instead. |
|
0 commit comments