This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 151
/
page.ts
163 lines (130 loc) 路 3.89 KB
/
page.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import { DappeteerElementHandle } from "./element";
import { DappeteerBrowser } from "./browser";
export interface DappeteerPage<P = unknown> {
$(selector: string): Promise<DappeteerElementHandle | null>;
$eval<T>(
selector: string,
evalFn: (e: HTMLElement) => Promise<T> | T
): Promise<T>;
$$eval<T>(
selector: string,
evalFn: (e: HTMLElement[]) => Promise<T[]> | T[]
): Promise<T[]>;
$$(selector: string): Promise<DappeteerElementHandle[]>;
getSource(): P;
url(): string;
browser(): DappeteerBrowser;
bringToFront(): Promise<void>;
goto(
url: string,
options?: {
timeout?: number;
waitUntil?: "load" | "domcontentloaded" | "networkidle" | "commit";
}
): Promise<void>;
title(): Promise<string>;
close(options?: { runBeforeUnload?: boolean }): Promise<void>;
reload(): Promise<void>;
setViewport(opts: { height: number; width: number }): Promise<void>;
waitForResponse(
urlOrPredicate: string | ((res: Response) => boolean | Promise<boolean>),
options?: {
timeout?: number;
}
): Promise<Response>;
waitForSelector(
selector: string,
opts?: Partial<{
visible: boolean;
detached: boolean;
hidden: boolean;
timeout: number;
}>
): Promise<DappeteerElementHandle>;
waitForSelectorIsGone(
selector: string,
opts?: Partial<{ timeout: number }>
): Promise<void>;
waitForXPath(
xpath: string,
opts?: Partial<{ visible: boolean; timeout: number }>
): Promise<DappeteerElementHandle>;
waitForTimeout(timeout: number): Promise<void>;
evaluate<Params, Result>(
evaluateFn: (params: Params) => Result | string,
params?: Params
): Promise<Result>;
screenshot(path: string): Promise<void>;
waitForFunction<Params extends Serializable>(
pageFunction: Function | string,
params?: Params
): Promise<void>;
exposeFunction(
name: string,
callback: Function | { default: Function }
): Promise<void>;
waitForNavigation(options?: { timeout: number });
type(
selector: string,
text: string,
options?: { delay: number }
): Promise<void>;
}
export type Unboxed<Arg> = Arg extends DappeteerElementHandle<any, infer T>
? T
: Arg extends [infer A0]
? [Unboxed<A0>]
: Arg extends [infer A0, infer A1]
? [Unboxed<A0>, Unboxed<A1>]
: Arg extends [infer A0, infer A1, infer A2]
? [Unboxed<A0>, Unboxed<A1>, Unboxed<A2>]
: Arg extends [infer A0, infer A1, infer A2, infer A3]
? [Unboxed<A0>, Unboxed<A1>, Unboxed<A2>, Unboxed<A3>]
: Arg extends Array<infer T>
? Array<Unboxed<T>>
: Arg extends object
? { [Key in keyof Arg]: Unboxed<Arg[Key]> }
: Arg;
export declare type Serializable =
| number
| string
| boolean
| null
| BigInt
| Serializable[]
| { [k: string]: Serializable };
export interface Response {
/**
* An object with the response HTTP headers. The header names are lower-cased. Note that this method does not return
* security-related headers, including cookie-related ones. You can use
* [response.allHeaders()](https://playwright.dev/docs/api/class-response#response-all-headers) for complete list of
* headers that include `cookie` information.
*/
headers(): { [key: string]: string };
/**
* Returns the JSON representation of response body.
*
* This method will throw if the response body is not parsable via `JSON.parse`.
*/
json(): Promise<any>;
/**
* Contains a boolean stating whether the response was successful (status in the range 200-299) or not.
*/
ok(): boolean;
/**
* Contains the status code of the response (e.g., 200 for a success).
*/
status(): number;
/**
* Contains the status text of the response (e.g. usually an "OK" for a success).
*/
statusText(): string;
/**
* Returns the text representation of response body.
*/
text(): Promise<string>;
/**
* Contains the URL of the response.
*/
url(): string;
}