@types/k6 0.51.1 → 0.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- k6/README.md +1 -1
- k6/browser.d.ts +3913 -0
- k6/experimental/browser.d.ts +991 -11
- k6/index.d.ts +1 -0
- k6/package.json +2 -2
k6/browser.d.ts
ADDED
|
@@ -0,0 +1,3913 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents event-specific properties. Refer to the events documentation for
|
|
3
|
+
* the lists of initial properties:
|
|
4
|
+
* - [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent)
|
|
5
|
+
* - [FocusEvent](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/FocusEvent)
|
|
6
|
+
* - [KeyboardEvent](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent)
|
|
7
|
+
* - [MouseEvent](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent)
|
|
8
|
+
* - [PointerEvent](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/PointerEvent)
|
|
9
|
+
* - [TouchEvent](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/TouchEvent)
|
|
10
|
+
* - [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event/Event)
|
|
11
|
+
*/
|
|
12
|
+
export type EvaluationArgument = object;
|
|
13
|
+
|
|
14
|
+
export type PageFunction<Arg, R> = string | ((arg: Unboxed<Arg>) => R);
|
|
15
|
+
|
|
16
|
+
export type Unboxed<Arg> = Arg extends [infer A0, infer A1] ? [Unboxed<A0>, Unboxed<A1>]
|
|
17
|
+
: Arg extends [infer A0, infer A1, infer A2] ? [Unboxed<A0>, Unboxed<A1>, Unboxed<A2>]
|
|
18
|
+
: Arg extends [infer A0, infer A1, infer A2, infer A3] ? [Unboxed<A0>, Unboxed<A1>, Unboxed<A2>, Unboxed<A3>]
|
|
19
|
+
: Arg extends Array<infer T> ? Array<Unboxed<T>>
|
|
20
|
+
: Arg extends object ? { [Key in keyof Arg]: Unboxed<Arg[Key]> }
|
|
21
|
+
: Arg;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* CPUProfile is the mandatory input to be passed into {@link Page}'s
|
|
25
|
+
* `throttleCPU` method.
|
|
26
|
+
*/
|
|
27
|
+
export interface CPUProfile {
|
|
28
|
+
/**
|
|
29
|
+
* rate as a slowdown factor (1 is no throttle, 2 is 2x slowdown, etc).
|
|
30
|
+
*/
|
|
31
|
+
rate: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* NetworkProfile is the mandatory input to be passed into {@link Page}'s
|
|
36
|
+
* `throttleNetwork` method.
|
|
37
|
+
*/
|
|
38
|
+
export interface NetworkProfile {
|
|
39
|
+
/**
|
|
40
|
+
* Minimum latency from request sent to response headers received (ms).
|
|
41
|
+
*/
|
|
42
|
+
latency: number;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Maximal aggregated download throughput (bytes/sec). -1 disables download
|
|
46
|
+
* throttling.
|
|
47
|
+
*/
|
|
48
|
+
download: number;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Maximal aggregated upload throughput (bytes/sec). -1 disables upload
|
|
52
|
+
* throttling.
|
|
53
|
+
*/
|
|
54
|
+
upload: number;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface SelectOptionsObject {
|
|
58
|
+
/**
|
|
59
|
+
* Matches by `option.value`.
|
|
60
|
+
*/
|
|
61
|
+
value?: string;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Matches by `option.label`.
|
|
65
|
+
*/
|
|
66
|
+
label?: string;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Matches by the index.
|
|
70
|
+
*/
|
|
71
|
+
index?: number;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export type ResourceType =
|
|
75
|
+
| "document"
|
|
76
|
+
| "stylesheet"
|
|
77
|
+
| "image"
|
|
78
|
+
| "media"
|
|
79
|
+
| "font"
|
|
80
|
+
| "script"
|
|
81
|
+
| "texttrack"
|
|
82
|
+
| "xhr"
|
|
83
|
+
| "fetch"
|
|
84
|
+
| "eventsource"
|
|
85
|
+
| "websocket"
|
|
86
|
+
| "manifest"
|
|
87
|
+
| "other";
|
|
88
|
+
export type MouseButton = "left" | "right" | "middle";
|
|
89
|
+
export type KeyboardModifier = "Alt" | "Control" | "Meta" | "Shift";
|
|
90
|
+
export type ElementState = "attached" | "detached" | "visible" | "hidden";
|
|
91
|
+
export type InputElementState = ElementState | "enabled" | "disabled" | "editable";
|
|
92
|
+
export type LifecycleEvent = "load" | "domcontentloaded" | "networkidle";
|
|
93
|
+
|
|
94
|
+
export interface TimeoutOptions {
|
|
95
|
+
/**
|
|
96
|
+
* Maximum time in milliseconds. Pass 0 to disable the timeout. Default is overridden by the setDefaultTimeout option on `BrowserContext` or `Page`.
|
|
97
|
+
* Defaults to 30000.
|
|
98
|
+
*/
|
|
99
|
+
timeout?: number;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface StrictnessOptions {
|
|
103
|
+
/**
|
|
104
|
+
* When `true`, the call requires selector to resolve to a single element.
|
|
105
|
+
* If given selector resolves to more than one element, the call throws
|
|
106
|
+
* an exception. Defaults to `false`.
|
|
107
|
+
*/
|
|
108
|
+
strict?: boolean;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface EventSequenceOptions {
|
|
112
|
+
/**
|
|
113
|
+
* Delay between events in milliseconds. Defaults to 0.
|
|
114
|
+
*/
|
|
115
|
+
delay?: number;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface File {
|
|
119
|
+
/**
|
|
120
|
+
* File name
|
|
121
|
+
*/
|
|
122
|
+
name: string;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* File type
|
|
126
|
+
*/
|
|
127
|
+
mimeType: string;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* File content
|
|
131
|
+
*/
|
|
132
|
+
buffer: ArrayBuffer;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export type ElementHandleOptions = {
|
|
136
|
+
/**
|
|
137
|
+
* Setting this to `true` will bypass the actionability checks (visible,
|
|
138
|
+
* stable, enabled). Defaults to `false`.
|
|
139
|
+
*/
|
|
140
|
+
force?: boolean;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* If set to `true` and a navigation occurs from performing this action, it will not wait for it to complete.
|
|
144
|
+
* Defaults to `false`.
|
|
145
|
+
*/
|
|
146
|
+
noWaitAfter?: boolean;
|
|
147
|
+
} & TimeoutOptions;
|
|
148
|
+
|
|
149
|
+
export type ElementHandlePointerOptions = ElementHandleOptions & {
|
|
150
|
+
/**
|
|
151
|
+
* Setting this to `true` will perform the actionability checks without
|
|
152
|
+
* performing the action. Useful to wait until the element is ready for the
|
|
153
|
+
* action without performing it. Defaults to `false`.
|
|
154
|
+
*/
|
|
155
|
+
trial?: boolean;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export type ElementClickOptions = ElementHandlePointerOptions & {
|
|
159
|
+
/**
|
|
160
|
+
* A point to use relative to the top left corner of the element. If not supplied,
|
|
161
|
+
* a visible point of the element is used.
|
|
162
|
+
*/
|
|
163
|
+
position?: { x: number; y: number };
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
export interface KeyboardModifierOptions {
|
|
167
|
+
/**
|
|
168
|
+
* `Alt`, `Control`, `Meta` or `Shift` modifiers keys pressed during the action.
|
|
169
|
+
* If not specified, currently pressed modifiers are used.
|
|
170
|
+
*/
|
|
171
|
+
modifiers?: KeyboardModifier[];
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export type KeyboardPressOptions =
|
|
175
|
+
& {
|
|
176
|
+
/**
|
|
177
|
+
* If set to `true` and a navigation occurs from performing this action, it
|
|
178
|
+
* will not wait for it to complete. Defaults to `false`.
|
|
179
|
+
*/
|
|
180
|
+
noWaitAfter?: boolean;
|
|
181
|
+
}
|
|
182
|
+
& EventSequenceOptions
|
|
183
|
+
& TimeoutOptions;
|
|
184
|
+
|
|
185
|
+
export type MouseMoveOptions = ElementClickOptions & KeyboardModifierOptions;
|
|
186
|
+
|
|
187
|
+
export type MouseClickOptions = {
|
|
188
|
+
/**
|
|
189
|
+
* The mouse button to use during the action.
|
|
190
|
+
* Defaults to `left`.
|
|
191
|
+
*/
|
|
192
|
+
button?: MouseButton;
|
|
193
|
+
} & EventSequenceOptions;
|
|
194
|
+
|
|
195
|
+
export type MouseMultiClickOptions = MouseClickOptions & {
|
|
196
|
+
/**
|
|
197
|
+
* The number of times the action is performed.
|
|
198
|
+
* Defaults to 1.
|
|
199
|
+
*/
|
|
200
|
+
clickCount?: number;
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
export interface MouseDownUpOptions {
|
|
204
|
+
/**
|
|
205
|
+
* The mouse button to use during the action.
|
|
206
|
+
* Defaults to `left`.
|
|
207
|
+
*/
|
|
208
|
+
button?: MouseButton;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Defaults to 1.
|
|
212
|
+
*/
|
|
213
|
+
clickCount?: number;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export type ContentLoadOptions = {
|
|
217
|
+
/**
|
|
218
|
+
* When to consider operation succeeded, defaults to `load`. Events can be
|
|
219
|
+
* either:
|
|
220
|
+
* - `'domcontentloaded'` - consider operation to be finished when the
|
|
221
|
+
* `DOMContentLoaded` event is fired.
|
|
222
|
+
* - `'load'` - consider operation to be finished when the `load` event is
|
|
223
|
+
* fired.
|
|
224
|
+
* - `'networkidle'` - **DISCOURAGED** consider operation to be finished
|
|
225
|
+
* when there are no network connections for at least `500` ms. Don't use
|
|
226
|
+
* this method for testing especially with chatty websites where the event
|
|
227
|
+
* may never fire, rely on web assertions to assess readiness instead.
|
|
228
|
+
*/
|
|
229
|
+
waitUntil?: LifecycleEvent;
|
|
230
|
+
} & TimeoutOptions;
|
|
231
|
+
|
|
232
|
+
export type NavigationOptions = {
|
|
233
|
+
/**
|
|
234
|
+
* Referer header value.
|
|
235
|
+
*/
|
|
236
|
+
referer?: string;
|
|
237
|
+
} & ContentLoadOptions;
|
|
238
|
+
|
|
239
|
+
export interface ResourceTiming {
|
|
240
|
+
/**
|
|
241
|
+
* Request start time in milliseconds elapsed since January 1, 1970 00:00:00 UTC
|
|
242
|
+
*/
|
|
243
|
+
startTime: number;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Time immediately before the browser starts the domain name lookup for the resource.
|
|
247
|
+
* The value is given in milliseconds relative to `startTime`, -1 if not available.
|
|
248
|
+
*/
|
|
249
|
+
domainLookupStart: number;
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Time immediately after the browser ends the domain name lookup for the resource.
|
|
253
|
+
* The value is given in milliseconds relative to `startTime`, -1 if not available.
|
|
254
|
+
*/
|
|
255
|
+
domainLookupEnd: number;
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Time immediately before the user agent starts establishing the connection to the server
|
|
259
|
+
* to retrieve the resource. The value is given in milliseconds relative to `startTime`,
|
|
260
|
+
* -1 if not available.
|
|
261
|
+
*/
|
|
262
|
+
connectStart: number;
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Time immediately before the browser starts the handshake process to secure the current
|
|
266
|
+
* connection. The value is given in milliseconds relative to `startTime`, -1 if not available.
|
|
267
|
+
*/
|
|
268
|
+
secureConnectionStart: number;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Time immediately after the user agent establishes the connection to the server
|
|
272
|
+
* to retrieve the resource. The value is given in milliseconds relative to `startTime`,
|
|
273
|
+
* -1 if not available.
|
|
274
|
+
*/
|
|
275
|
+
connectEnd: number;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Time immediately before the browser starts requesting the resource from the server,
|
|
279
|
+
* cache, or local resource. The value is given in milliseconds relative to `startTime`,
|
|
280
|
+
* -1 if not available.
|
|
281
|
+
*/
|
|
282
|
+
requestStart: number;
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Time immediately after the browser receives the first byte of the response from the server,
|
|
286
|
+
* cache, or local resource. The value is given in milliseconds relative to `startTime`,
|
|
287
|
+
* -1 if not available.
|
|
288
|
+
*/
|
|
289
|
+
responseStart: number;
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Time immediately after the browser receives the last byte of the resource or immediately
|
|
293
|
+
* before the transport connection is closed, whichever comes first. The value is given
|
|
294
|
+
* in milliseconds relative to `startTime`, -1 if not available.
|
|
295
|
+
*/
|
|
296
|
+
responseEnd: number;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
export interface SecurityDetailsObject {
|
|
300
|
+
/**
|
|
301
|
+
* Common Name component of the Issuer field. The value is extracted from the
|
|
302
|
+
* certificate. This should only be used for informational purposes.
|
|
303
|
+
*/
|
|
304
|
+
issuer?: string;
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* The specific TLS protocol used. For example `TLS 1.3`.
|
|
308
|
+
*/
|
|
309
|
+
protocol?: string;
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Common Name component of the Subject field. The value is extracted from the
|
|
313
|
+
* certificate. This should only be used for informational purposes.
|
|
314
|
+
*/
|
|
315
|
+
subjectName?: string;
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Unix timestamp (in seconds) specifying the exact date/time when this cert
|
|
319
|
+
* becomes valid.
|
|
320
|
+
*/
|
|
321
|
+
validFrom?: number;
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Unix timestamp (in seconds) specifying the exact date/time when this cert
|
|
325
|
+
* becomes invalid.
|
|
326
|
+
*/
|
|
327
|
+
validTo?: number;
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* String with hex encoded SHA256 fingerprint of the certificate. The value is
|
|
331
|
+
* extracted from the certificate.
|
|
332
|
+
*/
|
|
333
|
+
sanList?: string[];
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export interface Rect {
|
|
337
|
+
/**
|
|
338
|
+
* The x coordinate of the element in pixels.
|
|
339
|
+
* (0, 0) is the top left corner of the viewport.
|
|
340
|
+
*/
|
|
341
|
+
x: number;
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* The y coordinate of the element in pixels.
|
|
345
|
+
* (0, 0) is the top left corner of the viewport.
|
|
346
|
+
*/
|
|
347
|
+
y: number;
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* The width of the element in pixels.
|
|
351
|
+
*/
|
|
352
|
+
width: number;
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* The height of the element in pixels.
|
|
356
|
+
*/
|
|
357
|
+
height: number;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
export type ImageFormat = "jpeg" | "png";
|
|
361
|
+
|
|
362
|
+
export interface ScreenshotOptions {
|
|
363
|
+
/**
|
|
364
|
+
* The file path to save the image to. The screenshot type will be inferred from file extension.
|
|
365
|
+
*/
|
|
366
|
+
path?: string;
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* The screenshot format.
|
|
370
|
+
* @default 'png'
|
|
371
|
+
*/
|
|
372
|
+
type?: ImageFormat;
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Hide default white background and allow capturing screenshots with transparency.
|
|
376
|
+
* Not applicable to `jpeg` images.
|
|
377
|
+
* @default false
|
|
378
|
+
*/
|
|
379
|
+
omitBackground?: boolean;
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* The quality of the image, between 0-100. Not applicable to `png` images.
|
|
383
|
+
* @default 100
|
|
384
|
+
*/
|
|
385
|
+
quality?: number;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Methods to periodically check for a value.
|
|
390
|
+
* - `raf` - use `requestAnimationFrame` callback to poll
|
|
391
|
+
* - `mutation` - use a mutation observer
|
|
392
|
+
* - `interval` - use a polling interval
|
|
393
|
+
*/
|
|
394
|
+
export type PollingMethod = "raf" | "mutation" | "interval";
|
|
395
|
+
|
|
396
|
+
export interface PollingOptions {
|
|
397
|
+
/**
|
|
398
|
+
* Polling method to use.
|
|
399
|
+
* @default 'raf'
|
|
400
|
+
*/
|
|
401
|
+
polling?: "raf" | "mutation" | "interval";
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Polling interval in milliseconds if `polling` is set to `interval`.
|
|
405
|
+
*/
|
|
406
|
+
interval?: number;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
export interface ElementStateFilter {
|
|
410
|
+
/**
|
|
411
|
+
* The element state to filter for.
|
|
412
|
+
* @default 'visible'
|
|
413
|
+
*/
|
|
414
|
+
state?: ElementState;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* BrowserPermissions defines all the possible permissions that can be granted
|
|
419
|
+
* to the browser application.
|
|
420
|
+
*/
|
|
421
|
+
export type BrowserPermissions =
|
|
422
|
+
| "geolocation"
|
|
423
|
+
| "midi"
|
|
424
|
+
| "midi-sysex"
|
|
425
|
+
| "notifications"
|
|
426
|
+
| "camera"
|
|
427
|
+
| "microphone"
|
|
428
|
+
| "background-sync"
|
|
429
|
+
| "ambient-light-sensor"
|
|
430
|
+
| "accelerometer"
|
|
431
|
+
| "gyroscope"
|
|
432
|
+
| "magnetometer"
|
|
433
|
+
| "accessibility-events"
|
|
434
|
+
| "clipboard-read"
|
|
435
|
+
| "clipboard-write"
|
|
436
|
+
| "payment-handler";
|
|
437
|
+
|
|
438
|
+
export interface NewBrowserContextOptions {
|
|
439
|
+
/**
|
|
440
|
+
* Setting this to `true` will bypass a page's Content-Security-Policy.
|
|
441
|
+
* Defaults to `false`.
|
|
442
|
+
*/
|
|
443
|
+
bypassCSP?: boolean;
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* Emulates `'prefers-colors-scheme'` media feature, supported values
|
|
447
|
+
* are `'light'`, `'dark'`, and `'no-preference'`. Default to
|
|
448
|
+
* `'light'`.
|
|
449
|
+
*/
|
|
450
|
+
colorScheme?: "light" | "dark" | "no-preference";
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Sets the resolution ratio in physical pixels to the resolution in
|
|
454
|
+
* CSS pixels i.e. if set higher than 1, then images will look
|
|
455
|
+
* sharper on high pixel density screens. Defaults to 1.
|
|
456
|
+
*/
|
|
457
|
+
deviceScaleFactor?: number;
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* Contains additional HTTP headers to be sent with every request,
|
|
461
|
+
* where the keys are HTTP headers and values are HTTP header
|
|
462
|
+
* values. Defaults to null.
|
|
463
|
+
*/
|
|
464
|
+
extraHTTPHeaders?: { [key: string]: string };
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* Sets the user's geographical location. Defaults to null.
|
|
468
|
+
*/
|
|
469
|
+
geolocation?: {
|
|
470
|
+
/**
|
|
471
|
+
* latitude should be between -90 and 90.
|
|
472
|
+
*/
|
|
473
|
+
latitude: number;
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* longitude should be between -180 and 180.
|
|
477
|
+
*/
|
|
478
|
+
longitude: number;
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* accuracy should only be a non-negative number. Defaults to 0.
|
|
482
|
+
*/
|
|
483
|
+
accuracy: number;
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Whether to simulate a device with touch events. Defaults to
|
|
488
|
+
* `false`.
|
|
489
|
+
*/
|
|
490
|
+
hasTouch?: boolean;
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Sets the credentials for HTTP authentication using Basic Auth.
|
|
494
|
+
*/
|
|
495
|
+
httpCredentials?: {
|
|
496
|
+
username: string;
|
|
497
|
+
|
|
498
|
+
password: string;
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Whether to ignore HTTPS errors that may be caused by invalid
|
|
503
|
+
* certificates. Defaults to `false`.
|
|
504
|
+
*/
|
|
505
|
+
ignoreHTTPSErrors?: boolean;
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* Whether to simulate a mobile device. Defaults to `false`.
|
|
509
|
+
*/
|
|
510
|
+
isMobile?: boolean;
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* Whether to activate JavaScript support for the context. Defaults
|
|
514
|
+
* to `false`.
|
|
515
|
+
*/
|
|
516
|
+
javaScriptEnabled?: boolean;
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* Specifies the user's locale following ICU locale (e.g. 'en_US').
|
|
520
|
+
* Defaults to host system locale.
|
|
521
|
+
*/
|
|
522
|
+
locale?: string;
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* Whether to emulate an offline network. Defaults to `false`.
|
|
526
|
+
*/
|
|
527
|
+
offline?: boolean;
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* Permissions to grant for the context's pages. Defaults to
|
|
531
|
+
* null.
|
|
532
|
+
*/
|
|
533
|
+
permissions?: BrowserPermissions[];
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Minimizes the amount of motion by emulating the
|
|
537
|
+
* 'prefers-reduced-motion' media feature. Defaults to
|
|
538
|
+
* `'no-preference'`.
|
|
539
|
+
*/
|
|
540
|
+
reducedMotion?: "reduce" | "no-preference";
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* Sets a window screen size for all pages in the context. It can
|
|
544
|
+
* only be used when the viewport is set. Defaults to
|
|
545
|
+
* `{'width': 1280, 'height': 720}`.
|
|
546
|
+
*/
|
|
547
|
+
screen?: {
|
|
548
|
+
/**
|
|
549
|
+
* Page width in pixels.
|
|
550
|
+
*/
|
|
551
|
+
width: number;
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* Page height in pixels.
|
|
555
|
+
*/
|
|
556
|
+
height: number;
|
|
557
|
+
};
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* Changes the context's timezone. See ICU's metaZones.txt for a
|
|
561
|
+
* list of supported timezone IDs. Defaults to what is set on the
|
|
562
|
+
* system.
|
|
563
|
+
*/
|
|
564
|
+
timezoneID?: string;
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* Specifies the user agent to use in the context. Defaults to what
|
|
568
|
+
* is set on the by the browser.
|
|
569
|
+
*/
|
|
570
|
+
userAgent?: string;
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* Sets a viewport size for all pages in the context. null disables
|
|
574
|
+
* the default viewport. Defaults to `{'width': 1280, 'height': 720}`.
|
|
575
|
+
*/
|
|
576
|
+
viewport?: {
|
|
577
|
+
/**
|
|
578
|
+
* Page width in pixels.
|
|
579
|
+
*/
|
|
580
|
+
width: number;
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* Page height in pixels.
|
|
584
|
+
*/
|
|
585
|
+
height: number;
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* The `browser` named export is the entry point for all your tests,
|
|
591
|
+
* it interacts with the actual web browser via Chrome DevTools Protocol (CDP).
|
|
592
|
+
*/
|
|
593
|
+
export const browser: Browser;
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* `Browser` represents the main web browser instance.
|
|
597
|
+
*/
|
|
598
|
+
export interface Browser {
|
|
599
|
+
/**
|
|
600
|
+
* Closes the current `BrowserContext`. If there is no active
|
|
601
|
+
* `BrowserContext`, this method will throw an error.
|
|
602
|
+
*/
|
|
603
|
+
closeContext(): void;
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* Returns the current `BrowserContext`. There is a 1-to-1 mapping between
|
|
607
|
+
* `Browser` and `BrowserContext`. If no `BrowserContext` has been
|
|
608
|
+
* initialized, it will return null.
|
|
609
|
+
*/
|
|
610
|
+
context(): BrowserContext | null;
|
|
611
|
+
|
|
612
|
+
/**
|
|
613
|
+
* Indicates whether the CDP connection to the browser process is active or
|
|
614
|
+
* not.
|
|
615
|
+
*/
|
|
616
|
+
isConnected(): boolean;
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* Creates and returns a new `BrowserContext` if one hasn't already been
|
|
620
|
+
* initialized for the `Browser`. If one has already been initialized an
|
|
621
|
+
* error is thrown.
|
|
622
|
+
*
|
|
623
|
+
* There is a 1-to-1 mapping between `Browser` and `BrowserContext`. Due to
|
|
624
|
+
* this restriction, if one already exists, it must be closed first before
|
|
625
|
+
* creating a new one.
|
|
626
|
+
* @param options
|
|
627
|
+
*/
|
|
628
|
+
newContext(
|
|
629
|
+
options?: NewBrowserContextOptions,
|
|
630
|
+
): Promise<BrowserContext>;
|
|
631
|
+
|
|
632
|
+
/**
|
|
633
|
+
* Creates and returns a new `Page` in a new `BrowserContext` if a
|
|
634
|
+
* `BrowserContext` hasn't already been initialized for the `Browser`. If a
|
|
635
|
+
* `BrowserContext` has already been initialized an error is thrown.
|
|
636
|
+
*
|
|
637
|
+
* There is a 1-to-1 mapping between `Browser` and `BrowserContext`. Due to
|
|
638
|
+
* this restriction, if one already exists, it must be closed first before
|
|
639
|
+
* creating a new one.
|
|
640
|
+
* @param options
|
|
641
|
+
*/
|
|
642
|
+
newPage(
|
|
643
|
+
options?: NewBrowserContextOptions,
|
|
644
|
+
): Promise<Page>;
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* Returns the browser application's user agent.
|
|
648
|
+
*/
|
|
649
|
+
userAgent(): string;
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* Returns the browser application's version.
|
|
653
|
+
*/
|
|
654
|
+
version(): string;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* `BrowserContext` provides a way to operate multiple independent sessions, with
|
|
659
|
+
* separate pages, cache, and cookies.
|
|
660
|
+
*/
|
|
661
|
+
export interface BrowserContext {
|
|
662
|
+
/**
|
|
663
|
+
* Adds a script which will be evaluated in one of the following scenarios:
|
|
664
|
+
* - Whenever a page is created in the browser context or is navigated.
|
|
665
|
+
* - Whenever a child frame is attached or navigated in any page in the
|
|
666
|
+
* browser context. In this case, the script is evaluated in the context
|
|
667
|
+
* of the newly attached frame.
|
|
668
|
+
*
|
|
669
|
+
* The script is evaluated after the document is created but before any of
|
|
670
|
+
* its scripts were run. This is useful to amend the JavaScript environment,
|
|
671
|
+
* e.g. to override `Math.random`.
|
|
672
|
+
*
|
|
673
|
+
* **Usage**
|
|
674
|
+
*
|
|
675
|
+
* An example of overriding `Math.random` before the page loads:
|
|
676
|
+
*
|
|
677
|
+
* ```js
|
|
678
|
+
* const browserContext = await browser.newContext();
|
|
679
|
+
* await browserContext.addInitScript("Math.random = function(){return 0}");
|
|
680
|
+
*
|
|
681
|
+
* const page = await browserContext.newPage();
|
|
682
|
+
* await page.goto(url);
|
|
683
|
+
* ```
|
|
684
|
+
*
|
|
685
|
+
* @param script Script to be evaluated in all pages in the browser context.
|
|
686
|
+
*/
|
|
687
|
+
addInitScript(script: string | { content?: string }): Promise<void>;
|
|
688
|
+
|
|
689
|
+
/**
|
|
690
|
+
* Returns the `Browser` instance that this `BrowserContext` belongs to.
|
|
691
|
+
*/
|
|
692
|
+
browser(): Browser;
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* Adds {@link Cookie | cookies} into this {@link BrowserContext}.
|
|
696
|
+
*
|
|
697
|
+
* @param cookies The {@link Cookie | cookies} to add to this {@link BrowserContext}.
|
|
698
|
+
* @example
|
|
699
|
+
* ```js
|
|
700
|
+
* await context.addCookies([
|
|
701
|
+
* { name: 'foo', value: 'foovalue', sameSite: 'Lax', url: 'https://k6.io' },
|
|
702
|
+
* { name: 'bar', value: 'barvalue', sameSite: 'Strict', domain: 'test.k6.io', path: '/bar' },
|
|
703
|
+
* ]);
|
|
704
|
+
* ```
|
|
705
|
+
*/
|
|
706
|
+
addCookies(cookies: Cookie[]): Promise<void>;
|
|
707
|
+
|
|
708
|
+
/**
|
|
709
|
+
* Clears the {@link Cookie | cookies} in this {@link BrowserContext}.
|
|
710
|
+
*
|
|
711
|
+
* @example
|
|
712
|
+
* ```js
|
|
713
|
+
* await context.addCookies([{ name: 'foo', value: 'bar', url: 'https://k6.io' }]);
|
|
714
|
+
* context.cookies().length; // 1
|
|
715
|
+
* await context.clearCookies();
|
|
716
|
+
* context.cookies().length; // 0
|
|
717
|
+
* ```
|
|
718
|
+
*/
|
|
719
|
+
clearCookies(): Promise<void>;
|
|
720
|
+
|
|
721
|
+
/**
|
|
722
|
+
* Retrieves the {@link Cookie | cookies} in this {@link BrowserContext} filtered by provided URLs,
|
|
723
|
+
* or all {@link Cookie | cookies} if no URLs are provided.
|
|
724
|
+
*
|
|
725
|
+
* @param urls URLs to filter {@link Cookie | cookies} by.
|
|
726
|
+
* @example
|
|
727
|
+
* ```js
|
|
728
|
+
* // Get all cookies in the browser context
|
|
729
|
+
* const cookies = await context.cookies();
|
|
730
|
+
*
|
|
731
|
+
* // Get all cookies for the specified URLs
|
|
732
|
+
* const cookies = await context.cookies('https://k6.io', 'https://test.k6.io');
|
|
733
|
+
*
|
|
734
|
+
* // Get all cookies for the specified URLs and filter by name
|
|
735
|
+
* const cookies = await context.cookies('https://k6.io', 'https://test.k6.io').filter(c => c.name === 'foo');
|
|
736
|
+
* ```
|
|
737
|
+
*/
|
|
738
|
+
cookies(...urls: string[]): Promise<Cookie[]>;
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* Clears all permission overrides for the {@link BrowserContext}.
|
|
742
|
+
* ```js
|
|
743
|
+
* await context.clearPermissions();
|
|
744
|
+
* ```
|
|
745
|
+
*/
|
|
746
|
+
clearPermissions(): Promise<void>;
|
|
747
|
+
|
|
748
|
+
/**
|
|
749
|
+
* Close the `BrowserContext` and all its `Page`s.
|
|
750
|
+
*/
|
|
751
|
+
close(): Promise<void>;
|
|
752
|
+
|
|
753
|
+
/**
|
|
754
|
+
* Grants specified permissions to the {@link BrowserContext}.
|
|
755
|
+
* ```js
|
|
756
|
+
* await context.grantPermissions(['geolocation']);
|
|
757
|
+
* ```
|
|
758
|
+
*/
|
|
759
|
+
grantPermissions(
|
|
760
|
+
/**
|
|
761
|
+
* A string array of permissions to grant.
|
|
762
|
+
*/
|
|
763
|
+
permissions: BrowserPermissions[],
|
|
764
|
+
options?: {
|
|
765
|
+
/**
|
|
766
|
+
* The origin to grant permissions to, e.g. 'https://test.k6.com'.
|
|
767
|
+
*/
|
|
768
|
+
origin: string;
|
|
769
|
+
},
|
|
770
|
+
): Promise<void>;
|
|
771
|
+
|
|
772
|
+
/**
|
|
773
|
+
* Creates a new `Page` in the `BrowserContext`.
|
|
774
|
+
*/
|
|
775
|
+
newPage(): Promise<Page>;
|
|
776
|
+
|
|
777
|
+
/**
|
|
778
|
+
* Returns a list of `Page`s that belongs to the `BrowserContext`.
|
|
779
|
+
*/
|
|
780
|
+
pages(): Page[];
|
|
781
|
+
|
|
782
|
+
/**
|
|
783
|
+
* Sets the default navigation timeout in milliseconds.
|
|
784
|
+
*/
|
|
785
|
+
setDefaultNavigationTimeout(
|
|
786
|
+
/**
|
|
787
|
+
* The timeout in milliseconds.
|
|
788
|
+
*/
|
|
789
|
+
timeout: number,
|
|
790
|
+
): void;
|
|
791
|
+
|
|
792
|
+
/**
|
|
793
|
+
* Sets the default maximum timeout for all methods accepting a timeout
|
|
794
|
+
* option in milliseconds.
|
|
795
|
+
*/
|
|
796
|
+
setDefaultTimeout(
|
|
797
|
+
/**
|
|
798
|
+
* The timeout in milliseconds.
|
|
799
|
+
*/
|
|
800
|
+
timeout: number,
|
|
801
|
+
): void;
|
|
802
|
+
|
|
803
|
+
/**
|
|
804
|
+
* Sets the `BrowserContext`'s geolocation.
|
|
805
|
+
*/
|
|
806
|
+
setGeolocation(
|
|
807
|
+
geolocation?: {
|
|
808
|
+
/**
|
|
809
|
+
* latitude should be between -90 and 90.
|
|
810
|
+
*/
|
|
811
|
+
latitude: number;
|
|
812
|
+
|
|
813
|
+
/**
|
|
814
|
+
* longitude should be between -180 and 180.
|
|
815
|
+
*/
|
|
816
|
+
longitude: number;
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* accuracy should only be a non-negative number. Defaults to 0.
|
|
820
|
+
*/
|
|
821
|
+
accuracy: number;
|
|
822
|
+
},
|
|
823
|
+
): Promise<void>;
|
|
824
|
+
|
|
825
|
+
/**
|
|
826
|
+
* Toggles the `BrowserContext`'s connectivity on/off.
|
|
827
|
+
*/
|
|
828
|
+
setOffline(
|
|
829
|
+
/**
|
|
830
|
+
* Whether to emulate the BrowserContext being disconnected (`true`)
|
|
831
|
+
* or connected (`false`). Defaults to `false`.
|
|
832
|
+
*/
|
|
833
|
+
offline: boolean,
|
|
834
|
+
): Promise<void>;
|
|
835
|
+
|
|
836
|
+
/**
|
|
837
|
+
* Waits for the event to fire and passes its value into the predicate
|
|
838
|
+
* function. Currently the only supported event is 'page' which when used will
|
|
839
|
+
* return the new {@link Page} that was created after `waitForEvent` was called.
|
|
840
|
+
*
|
|
841
|
+
* @example
|
|
842
|
+
* ```js
|
|
843
|
+
* // Call waitForEvent with a predicate which will return true once at least
|
|
844
|
+
* // one page has been created.
|
|
845
|
+
* const promise = context.waitForEvent("page", {
|
|
846
|
+
* predicate: page => {
|
|
847
|
+
* if (++counter >= 1) {
|
|
848
|
+
* return true
|
|
849
|
+
* }
|
|
850
|
+
*
|
|
851
|
+
* return false
|
|
852
|
+
* }
|
|
853
|
+
* })
|
|
854
|
+
*
|
|
855
|
+
* // Now we create a page.
|
|
856
|
+
* const page = await context.newPage()
|
|
857
|
+
*
|
|
858
|
+
* // Wait for the predicate to pass.
|
|
859
|
+
* await promise
|
|
860
|
+
* ```
|
|
861
|
+
*/
|
|
862
|
+
waitForEvent(
|
|
863
|
+
/**
|
|
864
|
+
* Name of event to wait for. The only supported event is 'page'. If any
|
|
865
|
+
* other value is used an error will be thrown.
|
|
866
|
+
*/
|
|
867
|
+
event: "page",
|
|
868
|
+
/**
|
|
869
|
+
* This is an optional argument. It can either be a predicate function or
|
|
870
|
+
* an options object.
|
|
871
|
+
*/
|
|
872
|
+
optionsOrPredicate?: {
|
|
873
|
+
/**
|
|
874
|
+
* Optional function that will be called when the {@link Page} event is
|
|
875
|
+
* emitted. The event data will be passed to it and it must return true
|
|
876
|
+
* to continue.
|
|
877
|
+
*
|
|
878
|
+
* If {@link Page} is passed to predicate, this signals that a new page
|
|
879
|
+
* has been created.
|
|
880
|
+
*/
|
|
881
|
+
predicate?: (page: Page) => boolean;
|
|
882
|
+
|
|
883
|
+
/**
|
|
884
|
+
* Maximum time to wait in milliseconds. Defaults to 30000 milliseconds or
|
|
885
|
+
* the timeout set by setDefaultTimeout on the {@link BrowserContext}.
|
|
886
|
+
*/
|
|
887
|
+
timeout?: number;
|
|
888
|
+
} | ((page: Page) => boolean),
|
|
889
|
+
): Promise<Page>;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
/**
|
|
893
|
+
* {@link ConsoleMessage} objects are dispatched by page via the
|
|
894
|
+
* `page.on('console')` event. For each console message logged in the page,
|
|
895
|
+
* k6 browser delivers it to the registered handlers.
|
|
896
|
+
*
|
|
897
|
+
* ```js
|
|
898
|
+
* // Listen for all console log messages in the browser page and output them
|
|
899
|
+
* // in the test logs
|
|
900
|
+
* page.on('console', msg => console.log(msg.text()));
|
|
901
|
+
*
|
|
902
|
+
* // Listen for all console events and handle errors
|
|
903
|
+
* page.on('console', msg => {
|
|
904
|
+
* if (msg.type() === 'error')
|
|
905
|
+
* console.log(`Error text: "${msg.text()}"`);
|
|
906
|
+
* });
|
|
907
|
+
*
|
|
908
|
+
* // Deconstruct console log arguments
|
|
909
|
+
* await msg.args()[0].jsonValue(); // hello
|
|
910
|
+
* await msg.args()[1].jsonValue(); // 42
|
|
911
|
+
* ```
|
|
912
|
+
*/
|
|
913
|
+
export interface ConsoleMessage {
|
|
914
|
+
/**
|
|
915
|
+
* List of arguments passed to a `console` function call. See also
|
|
916
|
+
* `page.on('console')`.
|
|
917
|
+
*/
|
|
918
|
+
args(): JSHandle[];
|
|
919
|
+
|
|
920
|
+
/**
|
|
921
|
+
* The page that produced this console message, if any.
|
|
922
|
+
*/
|
|
923
|
+
page(): null | Page;
|
|
924
|
+
|
|
925
|
+
/**
|
|
926
|
+
* The text of the console message.
|
|
927
|
+
*/
|
|
928
|
+
text(): string;
|
|
929
|
+
|
|
930
|
+
/**
|
|
931
|
+
* One of the following values: `'log'`, `'debug'`, `'info'`, `'error'`,
|
|
932
|
+
* `'warning'`, `'dir'`, `'dirxml'`, `'table'`, `'trace'`, `'clear'`,
|
|
933
|
+
* `'startGroup'`, `'startGroupCollapsed'`, `'endGroup'`, `'assert'`,
|
|
934
|
+
* `'profile'`, `'profileEnd'`, `'count'`, `'timeEnd'`.
|
|
935
|
+
*/
|
|
936
|
+
type(): string;
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
/**
|
|
940
|
+
* {@link Cookie} represents a cookie in a {@link BrowserContext}.
|
|
941
|
+
*
|
|
942
|
+
* @see
|
|
943
|
+
* {@link BrowserContext} has methods to {@link BrowserContext.addCookies | add}, {@link BrowserContext.cookies | query} and {@link BrowserContext.clearCookies | clear} cookies.
|
|
944
|
+
*/
|
|
945
|
+
export interface Cookie {
|
|
946
|
+
/**
|
|
947
|
+
* The {@link Cookie | cookie}'s name.
|
|
948
|
+
*
|
|
949
|
+
* @defaultValue
|
|
950
|
+
* The default is `''`.
|
|
951
|
+
*/
|
|
952
|
+
name: string;
|
|
953
|
+
|
|
954
|
+
/**
|
|
955
|
+
* The {@link Cookie | cookie}'s value.
|
|
956
|
+
*
|
|
957
|
+
* @defaultValue
|
|
958
|
+
* The default is `''`.
|
|
959
|
+
*/
|
|
960
|
+
value: string;
|
|
961
|
+
|
|
962
|
+
/**
|
|
963
|
+
* The {@link Cookie | cookie}'s URL.
|
|
964
|
+
*
|
|
965
|
+
* Required unless one of {@link Cookie.domain | domain} or {@link Cookie.path | path} are specified.
|
|
966
|
+
*/
|
|
967
|
+
url?: string;
|
|
968
|
+
|
|
969
|
+
/**
|
|
970
|
+
* The {@link Cookie | cookie}'s domain.
|
|
971
|
+
*
|
|
972
|
+
* Required unless one of {@link Cookie.url | url} or {@link Cookie.path | path} are specified.
|
|
973
|
+
*/
|
|
974
|
+
domain?: string;
|
|
975
|
+
|
|
976
|
+
/**
|
|
977
|
+
* The {@link Cookie | cookie}'s path.
|
|
978
|
+
*
|
|
979
|
+
* Required unless one of {@link Cookie.url | url} or {@link Cookie.domain | domain} are specified.
|
|
980
|
+
*
|
|
981
|
+
* @defaultValue
|
|
982
|
+
* The default is `'/'`.
|
|
983
|
+
*/
|
|
984
|
+
path?: string;
|
|
985
|
+
|
|
986
|
+
/**
|
|
987
|
+
* The {@link Cookie | cookie}'s expiration date as the number of seconds since the UNIX epoch.
|
|
988
|
+
*
|
|
989
|
+
* If omitted, the {@link Cookie | cookie} becomes a session cookie.
|
|
990
|
+
*
|
|
991
|
+
* @defaultValue
|
|
992
|
+
* The default is `-1`, meaning a session cookie.
|
|
993
|
+
*/
|
|
994
|
+
expires?: number;
|
|
995
|
+
|
|
996
|
+
/**
|
|
997
|
+
* Whether the {@link Cookie | cookie} is http-only.
|
|
998
|
+
*
|
|
999
|
+
* @defaultValue
|
|
1000
|
+
* The default is `false`.
|
|
1001
|
+
*/
|
|
1002
|
+
httpOnly?: boolean;
|
|
1003
|
+
|
|
1004
|
+
/**
|
|
1005
|
+
* Whether the {@link Cookie | cookie} is secure.
|
|
1006
|
+
*
|
|
1007
|
+
* @defaultValue
|
|
1008
|
+
* The default is `false`.
|
|
1009
|
+
*/
|
|
1010
|
+
secure?: boolean;
|
|
1011
|
+
|
|
1012
|
+
/**
|
|
1013
|
+
* The {@link Cookie | cookie}'s same-site status.
|
|
1014
|
+
*
|
|
1015
|
+
* It can be one of `'Strict'`, `'Lax'`, or `'None'`.
|
|
1016
|
+
*
|
|
1017
|
+
* @defaultValue
|
|
1018
|
+
* The default is `'Lax'`.
|
|
1019
|
+
*/
|
|
1020
|
+
sameSite?: CookieSameSite;
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
/**
|
|
1024
|
+
* CookieSameSite represents the same-site status of a {@link Cookie | cookie}.
|
|
1025
|
+
*
|
|
1026
|
+
* @defaultValue
|
|
1027
|
+
* The default is `'Lax'`.
|
|
1028
|
+
*/
|
|
1029
|
+
export type CookieSameSite = "Strict" | "Lax" | "None";
|
|
1030
|
+
|
|
1031
|
+
/**
|
|
1032
|
+
* ElementHandle represents an in-page DOM element.
|
|
1033
|
+
*/
|
|
1034
|
+
export interface ElementHandle extends JSHandle {
|
|
1035
|
+
/**
|
|
1036
|
+
* Finds an element matching the specified selector in the `ElementHandle`'s subtree.
|
|
1037
|
+
* @param selector A selector to query element for.
|
|
1038
|
+
* @returns An `ElementHandle` pointing to the result element or `null`.
|
|
1039
|
+
*/
|
|
1040
|
+
$(selector: string): Promise<ElementHandle | null>;
|
|
1041
|
+
|
|
1042
|
+
/**
|
|
1043
|
+
* Finds all elements matching the specified selector in the `ElementHandle`'s subtree.
|
|
1044
|
+
* @param selector A selector to query element for.
|
|
1045
|
+
* @returns A list of `ElementHandle`s pointing to the result elements.
|
|
1046
|
+
*/
|
|
1047
|
+
$$(selector: string): Promise<ElementHandle[]>;
|
|
1048
|
+
|
|
1049
|
+
/**
|
|
1050
|
+
* This method returns the bounding box of the element.
|
|
1051
|
+
* @returns Element's bounding box.
|
|
1052
|
+
*/
|
|
1053
|
+
boundingBox(): Promise<Rect | null>;
|
|
1054
|
+
|
|
1055
|
+
/**
|
|
1056
|
+
* Checks the checkbox element.
|
|
1057
|
+
* @param options The options to use.
|
|
1058
|
+
*/
|
|
1059
|
+
check(options?: ElementClickOptions & StrictnessOptions): Promise<void>;
|
|
1060
|
+
|
|
1061
|
+
/**
|
|
1062
|
+
* Clicks the element.
|
|
1063
|
+
* @param options The options to use.
|
|
1064
|
+
* @returns A promise that resolves when the element is clicked.
|
|
1065
|
+
*/
|
|
1066
|
+
click(
|
|
1067
|
+
options?: {
|
|
1068
|
+
/**
|
|
1069
|
+
* The mouse button (`left`, `middle` or `right`) to use during the action.
|
|
1070
|
+
* Defaults to `left`.
|
|
1071
|
+
*/
|
|
1072
|
+
button?: MouseButton;
|
|
1073
|
+
|
|
1074
|
+
/**
|
|
1075
|
+
* The number of times the action is performed. Defaults to `1`.
|
|
1076
|
+
*/
|
|
1077
|
+
clickCount?: number;
|
|
1078
|
+
|
|
1079
|
+
/**
|
|
1080
|
+
* Milliseconds to wait between `mousedown` and `mouseup`. Defaults to `0`.
|
|
1081
|
+
*/
|
|
1082
|
+
delay?: number;
|
|
1083
|
+
|
|
1084
|
+
/**
|
|
1085
|
+
* Setting this to `true` will bypass the actionability checks (`visible`,
|
|
1086
|
+
* `stable`, `enabled`). Defaults to `false`.
|
|
1087
|
+
*/
|
|
1088
|
+
force?: boolean;
|
|
1089
|
+
|
|
1090
|
+
/**
|
|
1091
|
+
* `Alt`, `Control`, `Meta` or `Shift` modifiers keys pressed during the
|
|
1092
|
+
* action. If not specified, currently pressed modifiers are used,
|
|
1093
|
+
* otherwise defaults to `null`.
|
|
1094
|
+
*/
|
|
1095
|
+
modifiers?: KeyboardModifier[];
|
|
1096
|
+
|
|
1097
|
+
/**
|
|
1098
|
+
* If set to `true` and a navigation occurs from performing this action, it
|
|
1099
|
+
* will not wait for it to complete. Defaults to `false`.
|
|
1100
|
+
*/
|
|
1101
|
+
noWaitAfter?: boolean;
|
|
1102
|
+
|
|
1103
|
+
/**
|
|
1104
|
+
* A point to use relative to the top left corner of the element. If not
|
|
1105
|
+
* supplied, a visible point of the element is used.
|
|
1106
|
+
*/
|
|
1107
|
+
position?: {
|
|
1108
|
+
x: number;
|
|
1109
|
+
|
|
1110
|
+
y: number;
|
|
1111
|
+
};
|
|
1112
|
+
|
|
1113
|
+
/**
|
|
1114
|
+
* Maximum time in milliseconds. Defaults to `30` seconds. Default is
|
|
1115
|
+
* overridden by the `setDefaultTimeout` option on `BrowserContext` or
|
|
1116
|
+
* `page` methods.
|
|
1117
|
+
*
|
|
1118
|
+
* Setting the value to `0` will disable the timeout.
|
|
1119
|
+
*/
|
|
1120
|
+
timeout?: number;
|
|
1121
|
+
|
|
1122
|
+
/**
|
|
1123
|
+
* Setting this to `true` will perform the actionability checks without
|
|
1124
|
+
* performing the action. Useful to wait until the element is ready for the
|
|
1125
|
+
* action without performing it. Defaults to `false`.
|
|
1126
|
+
*/
|
|
1127
|
+
trial?: boolean;
|
|
1128
|
+
},
|
|
1129
|
+
): Promise<void>;
|
|
1130
|
+
|
|
1131
|
+
/**
|
|
1132
|
+
* Get the content frame for element handles.
|
|
1133
|
+
* @returns The content frame handle of the element handle.
|
|
1134
|
+
*/
|
|
1135
|
+
contentFrame(): Promise<Frame>;
|
|
1136
|
+
|
|
1137
|
+
/**
|
|
1138
|
+
* Double clicks the element.
|
|
1139
|
+
* @param options The options to use.
|
|
1140
|
+
*/
|
|
1141
|
+
dblclick(
|
|
1142
|
+
options?: {
|
|
1143
|
+
/**
|
|
1144
|
+
* The mouse button (`left`, `middle` or `right`) to use during the action.
|
|
1145
|
+
* Defaults to `left`.
|
|
1146
|
+
*/
|
|
1147
|
+
button?: MouseButton;
|
|
1148
|
+
|
|
1149
|
+
/**
|
|
1150
|
+
* Milliseconds to wait between `mousedown` and `mouseup`. Defaults to `0`.
|
|
1151
|
+
*/
|
|
1152
|
+
delay?: number;
|
|
1153
|
+
|
|
1154
|
+
/**
|
|
1155
|
+
* Setting this to `true` will bypass the actionability checks (`visible`,
|
|
1156
|
+
* `stable`, `enabled`). Defaults to `false`.
|
|
1157
|
+
*/
|
|
1158
|
+
force?: boolean;
|
|
1159
|
+
|
|
1160
|
+
/**
|
|
1161
|
+
* `Alt`, `Control`, `Meta` or `Shift` modifiers keys pressed during the
|
|
1162
|
+
* action. If not specified, currently pressed modifiers are used,
|
|
1163
|
+
* otherwise defaults to `null`.
|
|
1164
|
+
*/
|
|
1165
|
+
modifiers?: KeyboardModifier[];
|
|
1166
|
+
|
|
1167
|
+
/**
|
|
1168
|
+
* If set to `true` and a navigation occurs from performing this action, it
|
|
1169
|
+
* will not wait for it to complete. Defaults to `false`.
|
|
1170
|
+
*/
|
|
1171
|
+
noWaitAfter?: boolean;
|
|
1172
|
+
|
|
1173
|
+
/**
|
|
1174
|
+
* A point to use relative to the top left corner of the element. If not
|
|
1175
|
+
* supplied, a visible point of the element is used.
|
|
1176
|
+
*/
|
|
1177
|
+
position?: {
|
|
1178
|
+
x: number;
|
|
1179
|
+
|
|
1180
|
+
y: number;
|
|
1181
|
+
};
|
|
1182
|
+
|
|
1183
|
+
/**
|
|
1184
|
+
* Maximum time in milliseconds. Defaults to `30` seconds. Default is
|
|
1185
|
+
* overridden by the `setDefaultTimeout` option on `BrowserContext` or
|
|
1186
|
+
* `page` methods.
|
|
1187
|
+
*
|
|
1188
|
+
* Setting the value to `0` will disable the timeout.
|
|
1189
|
+
*/
|
|
1190
|
+
timeout?: number;
|
|
1191
|
+
|
|
1192
|
+
/**
|
|
1193
|
+
* Setting this to `true` will perform the actionability checks without
|
|
1194
|
+
* performing the action. Useful to wait until the element is ready for the
|
|
1195
|
+
* action without performing it. Defaults to `false`.
|
|
1196
|
+
*/
|
|
1197
|
+
trial?: boolean;
|
|
1198
|
+
},
|
|
1199
|
+
): Promise<void>;
|
|
1200
|
+
|
|
1201
|
+
/**
|
|
1202
|
+
* Dispatches a DOM event to the element.
|
|
1203
|
+
* @param type DOM event type: `"click"` etc.
|
|
1204
|
+
* @param eventInit Optional event-specific initialization properties.
|
|
1205
|
+
* @param options
|
|
1206
|
+
*/
|
|
1207
|
+
dispatchEvent(
|
|
1208
|
+
type: string,
|
|
1209
|
+
eventInit?: EvaluationArgument,
|
|
1210
|
+
): Promise<void>;
|
|
1211
|
+
|
|
1212
|
+
/**
|
|
1213
|
+
* Fill the `input` or `textarea` element with the provided `value`.
|
|
1214
|
+
* @param value Value to fill for the `input` or `textarea` element.
|
|
1215
|
+
* @param options Element handle options.
|
|
1216
|
+
*/
|
|
1217
|
+
fill(value: string, options?: ElementHandleOptions): Promise<void>;
|
|
1218
|
+
|
|
1219
|
+
/**
|
|
1220
|
+
* Focuses the element.
|
|
1221
|
+
*/
|
|
1222
|
+
focus(): Promise<void>;
|
|
1223
|
+
|
|
1224
|
+
/**
|
|
1225
|
+
* Fetch the element's attribute value.
|
|
1226
|
+
* @param name Attribute name to get the value for.
|
|
1227
|
+
* @returns Attribute value.
|
|
1228
|
+
*/
|
|
1229
|
+
getAttribute(name: string): Promise<string | null>;
|
|
1230
|
+
|
|
1231
|
+
/**
|
|
1232
|
+
* Scrolls element into view and hovers over its center point.
|
|
1233
|
+
* @param options Hover options.
|
|
1234
|
+
*/
|
|
1235
|
+
hover(options?: ElementClickOptions & KeyboardModifierOptions): Promise<void>;
|
|
1236
|
+
|
|
1237
|
+
/**
|
|
1238
|
+
* Returns the `element.innerHTML`.
|
|
1239
|
+
* @returns Element's innerHTML.
|
|
1240
|
+
*/
|
|
1241
|
+
innerHTML(): Promise<string>;
|
|
1242
|
+
|
|
1243
|
+
/**
|
|
1244
|
+
* Returns the `element.innerText`.
|
|
1245
|
+
* @returns Element's innerText.
|
|
1246
|
+
*/
|
|
1247
|
+
innerText(): Promise<string>;
|
|
1248
|
+
|
|
1249
|
+
/**
|
|
1250
|
+
* Returns `input.value` for the selected `input`, `textarea` or `select` element.
|
|
1251
|
+
* @returns The input value of the element.
|
|
1252
|
+
*/
|
|
1253
|
+
inputValue(options?: TimeoutOptions): Promise<string>;
|
|
1254
|
+
|
|
1255
|
+
/**
|
|
1256
|
+
* Checks if a checkbox or radio is checked.
|
|
1257
|
+
* @returns Whether the element is checked.
|
|
1258
|
+
*/
|
|
1259
|
+
isChecked(): Promise<boolean>;
|
|
1260
|
+
|
|
1261
|
+
/**
|
|
1262
|
+
* Checks if the element is disabled.
|
|
1263
|
+
* @returns Whether the element is disabled.
|
|
1264
|
+
*/
|
|
1265
|
+
isDisabled(): Promise<boolean>;
|
|
1266
|
+
|
|
1267
|
+
/**
|
|
1268
|
+
* Checks if the element is editable.
|
|
1269
|
+
* @returns Whether the element is editable.
|
|
1270
|
+
*/
|
|
1271
|
+
isEditable(): Promise<boolean>;
|
|
1272
|
+
|
|
1273
|
+
/**
|
|
1274
|
+
* Checks if the element is enabled.
|
|
1275
|
+
* @returns Whether the element is enabled.
|
|
1276
|
+
*/
|
|
1277
|
+
isEnabled(): Promise<boolean>;
|
|
1278
|
+
|
|
1279
|
+
/**
|
|
1280
|
+
* Checks if the element is hidden.
|
|
1281
|
+
* @returns Whether the element is hidden.
|
|
1282
|
+
*/
|
|
1283
|
+
isHidden(): Promise<boolean>;
|
|
1284
|
+
|
|
1285
|
+
/**
|
|
1286
|
+
* Checks if the element is visible.
|
|
1287
|
+
* @returns Whether the element is visible.
|
|
1288
|
+
*/
|
|
1289
|
+
isVisible(): Promise<boolean>;
|
|
1290
|
+
|
|
1291
|
+
/**
|
|
1292
|
+
* Returns the frame containing the given element.
|
|
1293
|
+
* @returns The frame that contains the element handle.
|
|
1294
|
+
*/
|
|
1295
|
+
ownerFrame(): Promise<Frame>;
|
|
1296
|
+
|
|
1297
|
+
/**
|
|
1298
|
+
* Focuses the element, and then uses `keyboard.down` and `keyboard.up` with the specified key.
|
|
1299
|
+
* @param key A keyboard key name or a single character to press.
|
|
1300
|
+
* @param options Keyboard press options.
|
|
1301
|
+
*/
|
|
1302
|
+
press(key: string, options?: KeyboardPressOptions): Promise<void>;
|
|
1303
|
+
|
|
1304
|
+
/**
|
|
1305
|
+
* This method scrolls element into view, if needed, and then captures a
|
|
1306
|
+
* screenshot of it.
|
|
1307
|
+
* @param options Screenshot options.
|
|
1308
|
+
* @returns An `ArrayBuffer` with the screenshot data.
|
|
1309
|
+
*/
|
|
1310
|
+
screenshot(options?: ScreenshotOptions & TimeoutOptions): Promise<ArrayBuffer>;
|
|
1311
|
+
|
|
1312
|
+
/**
|
|
1313
|
+
* This method checks whether the element is actionable using provided options, and
|
|
1314
|
+
* then tries to scroll it into view, unless it is completely visible.
|
|
1315
|
+
* @param options Element handle options.
|
|
1316
|
+
*/
|
|
1317
|
+
scrollIntoViewIfNeeded(options?: ElementHandleOptions): Promise<void>;
|
|
1318
|
+
|
|
1319
|
+
/**
|
|
1320
|
+
* Select one or more options of a `<select>` element which match the values.
|
|
1321
|
+
* @param values Values of options to select.
|
|
1322
|
+
* @param options Element handle options.
|
|
1323
|
+
* @returns List of selected options.
|
|
1324
|
+
*/
|
|
1325
|
+
selectOption(
|
|
1326
|
+
values: string | ElementHandle | SelectOptionsObject | string[] | ElementHandle[] | SelectOptionsObject[],
|
|
1327
|
+
options?: ElementHandleOptions,
|
|
1328
|
+
): Promise<string[]>;
|
|
1329
|
+
|
|
1330
|
+
/**
|
|
1331
|
+
* Focuses the element and selects all its text content.
|
|
1332
|
+
* @param options Element handle options.
|
|
1333
|
+
*/
|
|
1334
|
+
selectText(options?: ElementHandleOptions): Promise<void>;
|
|
1335
|
+
|
|
1336
|
+
/**
|
|
1337
|
+
* Sets the file input element's value to the specified files.
|
|
1338
|
+
*
|
|
1339
|
+
* To work with local files on the file system, use the experimental
|
|
1340
|
+
* fs module to load and read the file contents.
|
|
1341
|
+
*
|
|
1342
|
+
* The {@link ElementHandle | element handle} must be an [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
|
|
1343
|
+
* @param files
|
|
1344
|
+
* @param options
|
|
1345
|
+
*/
|
|
1346
|
+
setInputFiles(files: File | File[], options?: {
|
|
1347
|
+
/**
|
|
1348
|
+
* Maximum time in milliseconds. Pass 0 to disable the timeout. Default
|
|
1349
|
+
* is overridden by the setDefaultTimeout option on {@link BrowserContext} or
|
|
1350
|
+
* {@link Page}.
|
|
1351
|
+
* @default 30000
|
|
1352
|
+
*/
|
|
1353
|
+
timeout?: number;
|
|
1354
|
+
|
|
1355
|
+
/**
|
|
1356
|
+
* If set to `true` and a navigation occurs from performing this action, it
|
|
1357
|
+
* does not wait for it to complete.
|
|
1358
|
+
* @default false
|
|
1359
|
+
*/
|
|
1360
|
+
noWaitAfter?: boolean;
|
|
1361
|
+
}): Promise<void>;
|
|
1362
|
+
|
|
1363
|
+
/**
|
|
1364
|
+
* Scrolls element into view if needed, and then uses `page.tapscreen` to tap in the center of the element
|
|
1365
|
+
* or at the specified position.
|
|
1366
|
+
* @param options Tap options.
|
|
1367
|
+
*/
|
|
1368
|
+
tap(options?: MouseMoveOptions): Promise<void>;
|
|
1369
|
+
|
|
1370
|
+
/**
|
|
1371
|
+
* Returns the `node.textContent`.
|
|
1372
|
+
* @returns The text content of the element.
|
|
1373
|
+
*/
|
|
1374
|
+
textContent(): Promise<string | null>;
|
|
1375
|
+
|
|
1376
|
+
/**
|
|
1377
|
+
* Scrolls element into view, focuses element and types text.
|
|
1378
|
+
* @param text Text to type into the element.
|
|
1379
|
+
* @param options Typing options.
|
|
1380
|
+
*/
|
|
1381
|
+
type(text: string, options?: KeyboardPressOptions): Promise<void>;
|
|
1382
|
+
|
|
1383
|
+
/**
|
|
1384
|
+
* Scrolls element into view, and if it's an input element of type
|
|
1385
|
+
* checkbox that is already checked, clicks on it to mark it as unchecked.
|
|
1386
|
+
* @param options Click options.
|
|
1387
|
+
*/
|
|
1388
|
+
uncheck(options?: ElementClickOptions & StrictnessOptions): Promise<void>;
|
|
1389
|
+
|
|
1390
|
+
/**
|
|
1391
|
+
* Returns when the element satisfies the `state`.
|
|
1392
|
+
* @param state Wait for element to satisfy this state.
|
|
1393
|
+
* @param options Wait options.
|
|
1394
|
+
*/
|
|
1395
|
+
waitForElementState(state: InputElementState, options?: TimeoutOptions): Promise<void>;
|
|
1396
|
+
|
|
1397
|
+
/**
|
|
1398
|
+
* Returns when the child element matching `selector` satisfies the `state`.
|
|
1399
|
+
* @param selector A selector to query for.
|
|
1400
|
+
* @param options Wait options.
|
|
1401
|
+
*/
|
|
1402
|
+
waitForSelector(
|
|
1403
|
+
selector: string,
|
|
1404
|
+
options?: { state?: ElementState } & StrictnessOptions & TimeoutOptions,
|
|
1405
|
+
): Promise<ElementHandle>;
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
/**
|
|
1409
|
+
* Frame represents the frame within a page. A page is made up of hierarchy of frames.
|
|
1410
|
+
*/
|
|
1411
|
+
export interface Frame {
|
|
1412
|
+
/**
|
|
1413
|
+
* Finds an element matching the specified selector within the `Frame`.
|
|
1414
|
+
* @param selector A selector to query element for.
|
|
1415
|
+
* @returns An `ElementHandle` pointing to the result element or `null`.
|
|
1416
|
+
*/
|
|
1417
|
+
$(selector: string): Promise<ElementHandle | null>;
|
|
1418
|
+
|
|
1419
|
+
/**
|
|
1420
|
+
* Finds all elements matching the specified selector within the `Frame`.
|
|
1421
|
+
* @param selector A selector to query element for.
|
|
1422
|
+
* @returns A list of `ElementHandle`s pointing to the result elements.
|
|
1423
|
+
*/
|
|
1424
|
+
$$(selector: string): Promise<ElementHandle[]>;
|
|
1425
|
+
|
|
1426
|
+
/**
|
|
1427
|
+
* Checks the first checkbox element found that matches selector.
|
|
1428
|
+
* @param selector The selector to use.
|
|
1429
|
+
* @param options The options to use.
|
|
1430
|
+
*/
|
|
1431
|
+
check(selector: string, options?: ElementClickOptions & StrictnessOptions): Promise<void>;
|
|
1432
|
+
|
|
1433
|
+
/**
|
|
1434
|
+
* Uncheck the first found element that matches the selector.
|
|
1435
|
+
* @param selector The selector to use.
|
|
1436
|
+
* @param options The options to use.
|
|
1437
|
+
*/
|
|
1438
|
+
uncheck(selector: string, options?: ElementClickOptions & StrictnessOptions): Promise<void>;
|
|
1439
|
+
|
|
1440
|
+
/**
|
|
1441
|
+
* Clicks the element.
|
|
1442
|
+
* @param selector The selector to use.
|
|
1443
|
+
* @param options The options to use.
|
|
1444
|
+
* @returns A promise that resolves when the element is clicked.
|
|
1445
|
+
*/
|
|
1446
|
+
click(selector: string, options?: MouseMultiClickOptions & StrictnessOptions): Promise<void>;
|
|
1447
|
+
|
|
1448
|
+
/**
|
|
1449
|
+
* Double clicks the element.
|
|
1450
|
+
* @param selector The selector to use.
|
|
1451
|
+
* @param options The options to use.
|
|
1452
|
+
*/
|
|
1453
|
+
dblclick(selector: string, options?: MouseClickOptions & MouseMoveOptions & StrictnessOptions): Promise<void>;
|
|
1454
|
+
|
|
1455
|
+
/**
|
|
1456
|
+
* Fills out the first element found that matches the selector.
|
|
1457
|
+
* @param selector The selector to use.
|
|
1458
|
+
* @param value The value to fill.
|
|
1459
|
+
* @param options The options to use.
|
|
1460
|
+
*/
|
|
1461
|
+
fill(selector: string, value: string, options?: ElementHandleOptions & StrictnessOptions): Promise<void>;
|
|
1462
|
+
|
|
1463
|
+
/**
|
|
1464
|
+
* Focuses the first element found that matches the selector.
|
|
1465
|
+
* @param selector The selector to use.
|
|
1466
|
+
* @param options The options to use.
|
|
1467
|
+
*/
|
|
1468
|
+
focus(selector: string, options?: TimeoutOptions & StrictnessOptions): Promise<void>;
|
|
1469
|
+
|
|
1470
|
+
/**
|
|
1471
|
+
* Hovers the first element found that matches the selector.
|
|
1472
|
+
* @param selector The selector to use.
|
|
1473
|
+
* @param options The options to use.
|
|
1474
|
+
*/
|
|
1475
|
+
hover(selector: string, options?: ElementClickOptions & KeyboardModifierOptions & StrictnessOptions): Promise<void>;
|
|
1476
|
+
|
|
1477
|
+
/**
|
|
1478
|
+
* Taps the first element found that matches the selector.
|
|
1479
|
+
* @param selector The selector to use.
|
|
1480
|
+
* @param options The options to use.
|
|
1481
|
+
*/
|
|
1482
|
+
tap(selector: string, options?: ElementClickOptions & KeyboardModifierOptions & StrictnessOptions): Promise<void>;
|
|
1483
|
+
|
|
1484
|
+
/**
|
|
1485
|
+
* Press the given key for the first element found that matches the selector.
|
|
1486
|
+
* @param selector The selector to use.
|
|
1487
|
+
* @param key The key to press.
|
|
1488
|
+
* @param options The options to use.
|
|
1489
|
+
*/
|
|
1490
|
+
press(selector: string, key: string, options?: KeyboardPressOptions & StrictnessOptions): Promise<void>;
|
|
1491
|
+
|
|
1492
|
+
/**
|
|
1493
|
+
* Type the given text for the first element found that matches the selector.
|
|
1494
|
+
* @param selector The selector to use.
|
|
1495
|
+
* @param text The text to type.
|
|
1496
|
+
* @param options The options to use.
|
|
1497
|
+
*/
|
|
1498
|
+
type(selector: string, text: string, options?: KeyboardPressOptions & StrictnessOptions): Promise<void>;
|
|
1499
|
+
|
|
1500
|
+
/**
|
|
1501
|
+
* Select the given options and return the array of option values of the first element
|
|
1502
|
+
* found that matches the selector.
|
|
1503
|
+
* @param selector The selector to use.
|
|
1504
|
+
* @param values The values to select.
|
|
1505
|
+
* @returns The array of option values of the first element found.
|
|
1506
|
+
*/
|
|
1507
|
+
selectOption(
|
|
1508
|
+
selector: string,
|
|
1509
|
+
values: string | ElementHandle | SelectOptionsObject | string[] | ElementHandle[] | SelectOptionsObject[],
|
|
1510
|
+
options?: ElementHandleOptions & StrictnessOptions,
|
|
1511
|
+
): Promise<string[]>;
|
|
1512
|
+
|
|
1513
|
+
/**
|
|
1514
|
+
* Dispatches an event for the first element matching the selector.
|
|
1515
|
+
* @param selector The selector to use.
|
|
1516
|
+
* @param type The type of event to dispatch.
|
|
1517
|
+
* @param eventInit The event initialization properties.
|
|
1518
|
+
* @param options The options to use.
|
|
1519
|
+
*/
|
|
1520
|
+
dispatchEvent(
|
|
1521
|
+
selector: string,
|
|
1522
|
+
type: string,
|
|
1523
|
+
eventInit?: object,
|
|
1524
|
+
options?: TimeoutOptions & StrictnessOptions,
|
|
1525
|
+
): Promise<void>;
|
|
1526
|
+
|
|
1527
|
+
/**
|
|
1528
|
+
* Returns the value of the `pageFunction` invocation.
|
|
1529
|
+
*
|
|
1530
|
+
* A string can also be passed in instead of a function.
|
|
1531
|
+
*
|
|
1532
|
+
* @param pageFunction Function to be evaluated in the page context.
|
|
1533
|
+
* @param arg Optional argument to pass to `pageFunction`.
|
|
1534
|
+
*/
|
|
1535
|
+
evaluate<R, Arg>(pageFunction: PageFunction<Arg, R>, arg?: Arg): Promise<R>;
|
|
1536
|
+
|
|
1537
|
+
/**
|
|
1538
|
+
* Returns the value of the `pageFunction` invocation as a [JSHandle].
|
|
1539
|
+
*
|
|
1540
|
+
* The only difference between page.evaluate(pageFunction[, arg]) and
|
|
1541
|
+
* page.evaluateHandle(pageFunction[, arg]) is that
|
|
1542
|
+
* page.evaluateHandle(pageFunction[, arg])returns [JSHandle].
|
|
1543
|
+
*
|
|
1544
|
+
* @param pageFunction Function to be evaluated in the page context.
|
|
1545
|
+
* @param arg Optional argument to pass to `pageFunction`.
|
|
1546
|
+
*/
|
|
1547
|
+
evaluateHandle<R, Arg>(pageFunction: PageFunction<Arg, R>, arg?: Arg): Promise<JSHandle<R>>;
|
|
1548
|
+
|
|
1549
|
+
/**
|
|
1550
|
+
* Get the page that owns frame.
|
|
1551
|
+
* @returns The page that owns frame.
|
|
1552
|
+
*/
|
|
1553
|
+
page(): Page;
|
|
1554
|
+
|
|
1555
|
+
/**
|
|
1556
|
+
* Get the parent frame.
|
|
1557
|
+
* @returns The parent frame, or `null` if there is no parent frame.
|
|
1558
|
+
*/
|
|
1559
|
+
parentFrame(): Frame | null;
|
|
1560
|
+
|
|
1561
|
+
/**
|
|
1562
|
+
* Get a list of all child frames.
|
|
1563
|
+
* @returns A list of all child frames.
|
|
1564
|
+
*/
|
|
1565
|
+
childFrames(): Frame[];
|
|
1566
|
+
|
|
1567
|
+
/**
|
|
1568
|
+
* Get the `ElementHandle` for this frame.
|
|
1569
|
+
* @returns The `ElementHandle` for this frame.
|
|
1570
|
+
*/
|
|
1571
|
+
frameElement(): Promise<ElementHandle>;
|
|
1572
|
+
|
|
1573
|
+
/**
|
|
1574
|
+
* Navigate the frame to the specified URL and return a HTTP response object.
|
|
1575
|
+
* @param url The URL to navigate to.
|
|
1576
|
+
* @param options The options to use.
|
|
1577
|
+
* @returns A promise that resolves to the HTTP response object.
|
|
1578
|
+
*/
|
|
1579
|
+
goto(url: string, options?: NavigationOptions): Promise<Response | null>;
|
|
1580
|
+
|
|
1581
|
+
/**
|
|
1582
|
+
* Replace the entire HTML document content.
|
|
1583
|
+
* @param html The HTML to use.
|
|
1584
|
+
* @param options The options to use.
|
|
1585
|
+
*/
|
|
1586
|
+
setContent(html: string, options?: ContentLoadOptions): Promise<void>;
|
|
1587
|
+
|
|
1588
|
+
/**
|
|
1589
|
+
* Get the name of the frame.
|
|
1590
|
+
* @returns The name of the frame.
|
|
1591
|
+
*/
|
|
1592
|
+
name(): string;
|
|
1593
|
+
|
|
1594
|
+
/**
|
|
1595
|
+
* Get the title of the frame.
|
|
1596
|
+
* @returns The title of the frame.
|
|
1597
|
+
*/
|
|
1598
|
+
title(): Promise<string>;
|
|
1599
|
+
|
|
1600
|
+
/**
|
|
1601
|
+
* Get the URL of the frame.
|
|
1602
|
+
* @returns The URL of the frame.
|
|
1603
|
+
*/
|
|
1604
|
+
url(): string;
|
|
1605
|
+
|
|
1606
|
+
/**
|
|
1607
|
+
* Get the HTML content of the frame.
|
|
1608
|
+
* @returns The HTML content of the frame.
|
|
1609
|
+
*/
|
|
1610
|
+
content(): Promise<string>;
|
|
1611
|
+
|
|
1612
|
+
/**
|
|
1613
|
+
* Get whether the frame is detached or not.
|
|
1614
|
+
* @returns `true` if the frame is detached, `false` otherwise.
|
|
1615
|
+
*/
|
|
1616
|
+
isDetached(): boolean;
|
|
1617
|
+
|
|
1618
|
+
/**
|
|
1619
|
+
* Сreates and returns a new locator for this frame.
|
|
1620
|
+
* @param selector The selector to use.
|
|
1621
|
+
* @returns The new locator.
|
|
1622
|
+
*/
|
|
1623
|
+
locator(selector: string): Locator;
|
|
1624
|
+
|
|
1625
|
+
/**
|
|
1626
|
+
* Get the `innerHTML` attribute of the first element found that matches the selector.
|
|
1627
|
+
* @param selector The selector to use.
|
|
1628
|
+
* @param options The options to use.
|
|
1629
|
+
* @returns The `innerHTML` attribute of the first element found.
|
|
1630
|
+
*/
|
|
1631
|
+
innerHTML(selector: string, options?: TimeoutOptions & StrictnessOptions): Promise<string>;
|
|
1632
|
+
|
|
1633
|
+
/**
|
|
1634
|
+
* Get the `innerText` attribute of the first element found that matches the selector.
|
|
1635
|
+
* @param selector The selector to use.
|
|
1636
|
+
* @param options The options to use.
|
|
1637
|
+
* @returns The `innerText` attribute of the first element found.
|
|
1638
|
+
*/
|
|
1639
|
+
innerText(selector: string, options?: TimeoutOptions & StrictnessOptions): Promise<string>;
|
|
1640
|
+
|
|
1641
|
+
/**
|
|
1642
|
+
* Get the text content of the first element found that matches the selector.
|
|
1643
|
+
* @param selector The selector to use.
|
|
1644
|
+
* @param options The options to use.
|
|
1645
|
+
* @returns The text content of the first element found.
|
|
1646
|
+
*/
|
|
1647
|
+
textContent(selector: string, options?: TimeoutOptions & StrictnessOptions): Promise<string>;
|
|
1648
|
+
|
|
1649
|
+
/**
|
|
1650
|
+
* Get the value of an attribute of the first element found that matches the selector.
|
|
1651
|
+
* @param selector The selector to use.
|
|
1652
|
+
* @param name The name of the attribute to get.
|
|
1653
|
+
* @param options The options to use.
|
|
1654
|
+
* @returns The value of the attribute.
|
|
1655
|
+
*/
|
|
1656
|
+
getAttribute(selector: string, name: string, options?: TimeoutOptions & StrictnessOptions): Promise<string>;
|
|
1657
|
+
|
|
1658
|
+
/**
|
|
1659
|
+
* Get the input value of the first element found that matches the selector.
|
|
1660
|
+
* @param selector The selector to use.
|
|
1661
|
+
* @param options The options to use.
|
|
1662
|
+
* @returns The input value of the first element found.
|
|
1663
|
+
*/
|
|
1664
|
+
inputValue(selector: string, options?: TimeoutOptions & StrictnessOptions): Promise<string>;
|
|
1665
|
+
|
|
1666
|
+
/**
|
|
1667
|
+
* Get the `checked` attribute of the first checkbox element found that matches the selector.
|
|
1668
|
+
* @param selector The selector to use.
|
|
1669
|
+
* @param options The options to use.
|
|
1670
|
+
* @returns `true` if the checkbox is checked, `false` otherwise.
|
|
1671
|
+
*/
|
|
1672
|
+
isChecked(selector: string, options?: TimeoutOptions & StrictnessOptions): Promise<boolean>;
|
|
1673
|
+
|
|
1674
|
+
/**
|
|
1675
|
+
* Get whether the first element found that matches the selector is disabled or not.
|
|
1676
|
+
* @param selector The selector to use.
|
|
1677
|
+
* @param options The options to use.
|
|
1678
|
+
* @returns `true` if the element is disabled, `false` otherwise.
|
|
1679
|
+
*/
|
|
1680
|
+
isDisabled(selector: string, options?: TimeoutOptions & StrictnessOptions): Promise<boolean>;
|
|
1681
|
+
|
|
1682
|
+
/**
|
|
1683
|
+
* Get whether the first element found that matches the selector is enabled or not.
|
|
1684
|
+
* @param selector The selector to use.
|
|
1685
|
+
* @param options The options to use.
|
|
1686
|
+
* @returns `true` if the element is enabled, `false` otherwise.
|
|
1687
|
+
*/
|
|
1688
|
+
isEnabled(selector: string, options?: TimeoutOptions & StrictnessOptions): Promise<boolean>;
|
|
1689
|
+
|
|
1690
|
+
/**
|
|
1691
|
+
* Get whether the first element found that matches the selector is editable or not.
|
|
1692
|
+
* @param selector The selector to use.
|
|
1693
|
+
* @param options The options to use.
|
|
1694
|
+
* @returns `true` if the element is editable, `false` otherwise.
|
|
1695
|
+
*/
|
|
1696
|
+
isEditable(selector: string, options?: TimeoutOptions & StrictnessOptions): Promise<boolean>;
|
|
1697
|
+
|
|
1698
|
+
/**
|
|
1699
|
+
* Get whether the first element found that matches the selector is hidden or not.
|
|
1700
|
+
* @param selector The selector to use.
|
|
1701
|
+
* @param options The options to use.
|
|
1702
|
+
* @returns `true` if the element is hidden, `false` otherwise.
|
|
1703
|
+
*/
|
|
1704
|
+
isHidden(selector: string, options?: StrictnessOptions): Promise<boolean>;
|
|
1705
|
+
|
|
1706
|
+
/**
|
|
1707
|
+
* Get whether the first element found that matches the selector is visible or not.
|
|
1708
|
+
* @param selector The selector to use.
|
|
1709
|
+
* @param options The options to use.
|
|
1710
|
+
* @returns `true` if the element is visible, `false` otherwise.
|
|
1711
|
+
*/
|
|
1712
|
+
isVisible(selector: string, options?: StrictnessOptions): Promise<boolean>;
|
|
1713
|
+
|
|
1714
|
+
/**
|
|
1715
|
+
* Sets the file input element's value to the specified files.
|
|
1716
|
+
*
|
|
1717
|
+
* To work with local files on the file system, use the experimental
|
|
1718
|
+
* fs module to load and read the file contents.
|
|
1719
|
+
*
|
|
1720
|
+
* This method expects a `selector` to point to an
|
|
1721
|
+
* [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
|
|
1722
|
+
* @param selector A selector to search for an element. If there are multiple
|
|
1723
|
+
* elements satisfying the selector, the first will be used.
|
|
1724
|
+
* @param files
|
|
1725
|
+
* @param options
|
|
1726
|
+
*/
|
|
1727
|
+
setInputFiles(selector: string, files: File | File[], options?: {
|
|
1728
|
+
/**
|
|
1729
|
+
* Maximum time in milliseconds. Pass 0 to disable the timeout. Default
|
|
1730
|
+
* is overridden by the setDefaultTimeout option on {@link BrowserContext} or
|
|
1731
|
+
* {@link Page}
|
|
1732
|
+
* @default 30000
|
|
1733
|
+
*/
|
|
1734
|
+
timeout?: number;
|
|
1735
|
+
|
|
1736
|
+
/**
|
|
1737
|
+
* If set to `true` and a navigation occurs from performing this action, it
|
|
1738
|
+
* will not wait for it to complete.
|
|
1739
|
+
* @default false
|
|
1740
|
+
*/
|
|
1741
|
+
noWaitAfter?: boolean;
|
|
1742
|
+
}): Promise<void>;
|
|
1743
|
+
|
|
1744
|
+
/**
|
|
1745
|
+
* Wait for the given function to return a truthy value.
|
|
1746
|
+
* @param predicate The function to call and wait for.
|
|
1747
|
+
* @param options The options to use.
|
|
1748
|
+
*/
|
|
1749
|
+
waitForFunction<R, Arg>(
|
|
1750
|
+
pageFunction: PageFunction<Arg, R>,
|
|
1751
|
+
options?: PollingOptions & TimeoutOptions,
|
|
1752
|
+
arg?: Arg,
|
|
1753
|
+
): Promise<JSHandle<R>>;
|
|
1754
|
+
|
|
1755
|
+
/**
|
|
1756
|
+
* Wait for the given load state to be reached.
|
|
1757
|
+
* This will unblock if that lifecycle event has already been received.
|
|
1758
|
+
* @param state The load state to wait for, defaults to `load`.
|
|
1759
|
+
* @param options The options to use.
|
|
1760
|
+
*/
|
|
1761
|
+
waitForLoadState(state?: LifecycleEvent, options?: TimeoutOptions): Promise<void>;
|
|
1762
|
+
|
|
1763
|
+
/**
|
|
1764
|
+
* Waits for the navigation event to happen.
|
|
1765
|
+
* @param options The options to use.
|
|
1766
|
+
* @returns A promise that resolves to the response of the navigation when it happens.
|
|
1767
|
+
*/
|
|
1768
|
+
waitForNavigation(options?: ContentLoadOptions): Promise<Response | null>;
|
|
1769
|
+
|
|
1770
|
+
/**
|
|
1771
|
+
* Wait for the given selector to match the waiting criteria.
|
|
1772
|
+
* @param selector The selector to use.
|
|
1773
|
+
* @param options The options to use.
|
|
1774
|
+
* @returns The first element found that matches the selector.
|
|
1775
|
+
*/
|
|
1776
|
+
waitForSelector(
|
|
1777
|
+
selector: string,
|
|
1778
|
+
options?: ElementStateFilter & TimeoutOptions & StrictnessOptions,
|
|
1779
|
+
): Promise<ElementHandle>;
|
|
1780
|
+
|
|
1781
|
+
/**
|
|
1782
|
+
* Wait for the given timeout to elapse.
|
|
1783
|
+
* @param timeout The timeout to wait for.
|
|
1784
|
+
*/
|
|
1785
|
+
waitForTimeout(timeout: number): Promise<void>;
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1788
|
+
/**
|
|
1789
|
+
* JSHandle represents an in-page JavaScript object.
|
|
1790
|
+
*/
|
|
1791
|
+
export interface JSHandle<T = any> {
|
|
1792
|
+
/**
|
|
1793
|
+
* Returns either `null` or the object handle itself, if the object handle is
|
|
1794
|
+
* an instance of `ElementHandle`.
|
|
1795
|
+
* @returns The ElementHandle if available.
|
|
1796
|
+
*/
|
|
1797
|
+
asElement(): Promise<ElementHandle | null>;
|
|
1798
|
+
|
|
1799
|
+
/**
|
|
1800
|
+
* Stops referencing the element handle.
|
|
1801
|
+
*/
|
|
1802
|
+
dispose(): Promise<void>;
|
|
1803
|
+
|
|
1804
|
+
/**
|
|
1805
|
+
* Evaluates the page function and returns its return value.
|
|
1806
|
+
* This method passes this handle as the first argument to the page function.
|
|
1807
|
+
* @param pageFunction The function to be evaluated.
|
|
1808
|
+
* @param args The arguments to pass to the page function.
|
|
1809
|
+
* @returns The return value of `pageFunction`.
|
|
1810
|
+
*/
|
|
1811
|
+
evaluate<R, Arg>(pageFunction: PageFunction<Arg, R>, arg?: Arg): Promise<R>;
|
|
1812
|
+
|
|
1813
|
+
/**
|
|
1814
|
+
* Evaluates the page function and returns a `JSHandle`.
|
|
1815
|
+
* This method passes this handle as the first argument to the page function.
|
|
1816
|
+
* Unlike `evaluate`, `evaluateHandle` returns the value as a `JSHandle`
|
|
1817
|
+
* @param pageFunction The function to be evaluated.
|
|
1818
|
+
* @param args The arguments to pass to the page function.
|
|
1819
|
+
* @returns A JSHandle of the return value of `pageFunction`.
|
|
1820
|
+
*/
|
|
1821
|
+
evaluateHandle<R, Arg>(pageFunction: PageFunction<Arg, R>, arg?: Arg): Promise<JSHandle<R>>;
|
|
1822
|
+
|
|
1823
|
+
/**
|
|
1824
|
+
* Fetches a map with own property names of of the `JSHandle` with their values as
|
|
1825
|
+
* `JSHandle` instances.
|
|
1826
|
+
* @returns A map with property names as keys and `JSHandle` instances for the property values.
|
|
1827
|
+
*/
|
|
1828
|
+
getProperties(): Promise<Map<string, JSHandle>>;
|
|
1829
|
+
|
|
1830
|
+
/**
|
|
1831
|
+
* Fetches a JSON representation of the object.
|
|
1832
|
+
* @returns A JSON representation of the object.
|
|
1833
|
+
*/
|
|
1834
|
+
jsonValue(): Promise<any>;
|
|
1835
|
+
}
|
|
1836
|
+
|
|
1837
|
+
/**
|
|
1838
|
+
* Keyboard provides an API for managing a virtual keyboard.
|
|
1839
|
+
*/
|
|
1840
|
+
export interface Keyboard {
|
|
1841
|
+
/**
|
|
1842
|
+
* Sends a key down message to a session target.
|
|
1843
|
+
* A superset of the key values can be found [here](https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values).
|
|
1844
|
+
* @param key Name of key to press, such as `ArrowLeft`.
|
|
1845
|
+
*/
|
|
1846
|
+
down(key: string): Promise<void>;
|
|
1847
|
+
|
|
1848
|
+
/**
|
|
1849
|
+
* Dispatches an `input` event with the given `text`.
|
|
1850
|
+
* This method does not emit `keyDown`, `keyUp` or `keyPress` events.
|
|
1851
|
+
* @param text Event text.
|
|
1852
|
+
*/
|
|
1853
|
+
insertText(text: string): Promise<void>;
|
|
1854
|
+
|
|
1855
|
+
/**
|
|
1856
|
+
* Sends a key press message to a session target.
|
|
1857
|
+
* A press message consists of successive key down and up messages.
|
|
1858
|
+
* @param key Sequence of keys to press.
|
|
1859
|
+
* @param options Specifies the typing options.
|
|
1860
|
+
*/
|
|
1861
|
+
press(key: string, options?: { delay?: number }): Promise<void>;
|
|
1862
|
+
|
|
1863
|
+
/**
|
|
1864
|
+
* Type sends a `press` message to a session target for each character in text.
|
|
1865
|
+
* It sends an insertText message if a character is not among
|
|
1866
|
+
* valid characters in the keyboard's layout.
|
|
1867
|
+
* Modifier keys `Shift`, `Control`, `Alt`, `Meta` are _not_ respected.
|
|
1868
|
+
* @param text A text to type into a focused element.
|
|
1869
|
+
* @param options Specifies the typing options.
|
|
1870
|
+
*/
|
|
1871
|
+
type(text: string, options?: { delay?: number }): Promise<void>;
|
|
1872
|
+
|
|
1873
|
+
/**
|
|
1874
|
+
* Sends a key up message to a session target.
|
|
1875
|
+
* A superset of the key values can be found [here](https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values).
|
|
1876
|
+
* @param key Name of key to release, such as `ArrowLeft`.
|
|
1877
|
+
*/
|
|
1878
|
+
up(key: string): Promise<void>;
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1881
|
+
/**
|
|
1882
|
+
* The Locator API makes it easier to work with dynamically changing elements.
|
|
1883
|
+
* Some of the benefits of using it over existing ways to locate an element
|
|
1884
|
+
* (e.g. Page.$()) include:
|
|
1885
|
+
*
|
|
1886
|
+
* - Helps with writing robust tests by finding an element even if the
|
|
1887
|
+
* underlying frame navigates.
|
|
1888
|
+
* - Makes it easier to work with dynamic web pages and SPAs built with Svelte,
|
|
1889
|
+
* React, Vue, etc.
|
|
1890
|
+
*/
|
|
1891
|
+
export interface Locator {
|
|
1892
|
+
/**
|
|
1893
|
+
* Clears text boxes and input fields of any existing values.
|
|
1894
|
+
*
|
|
1895
|
+
* **Usage**
|
|
1896
|
+
*
|
|
1897
|
+
* ```js
|
|
1898
|
+
* // Clears the input field matching the selector.
|
|
1899
|
+
* page.locator('input[name="login"]').clear();
|
|
1900
|
+
* ```
|
|
1901
|
+
*
|
|
1902
|
+
* @param options Options to use.
|
|
1903
|
+
*/
|
|
1904
|
+
clear(options?: ElementHandleOptions): Promise<void>;
|
|
1905
|
+
|
|
1906
|
+
/**
|
|
1907
|
+
* Mouse click on the chosen element.
|
|
1908
|
+
* @param options Options to use.
|
|
1909
|
+
* @returns Promise which resolves when the element is successfully clicked.
|
|
1910
|
+
*/
|
|
1911
|
+
click(options?: MouseMoveOptions & MouseMultiClickOptions): Promise<void>;
|
|
1912
|
+
|
|
1913
|
+
/**
|
|
1914
|
+
* Mouse double click on the chosen element.
|
|
1915
|
+
* @param options Options to use.
|
|
1916
|
+
*/
|
|
1917
|
+
dblclick(options?: MouseMoveOptions & MouseMultiClickOptions): Promise<void>;
|
|
1918
|
+
|
|
1919
|
+
/**
|
|
1920
|
+
* Use this method to select an `input type="checkbox"`.
|
|
1921
|
+
* @param options Options to use.
|
|
1922
|
+
*/
|
|
1923
|
+
check(options?: ElementClickOptions): Promise<void>;
|
|
1924
|
+
|
|
1925
|
+
/**
|
|
1926
|
+
* Use this method to unselect an `input type="checkbox"`.
|
|
1927
|
+
* @param options Options to use.
|
|
1928
|
+
*/
|
|
1929
|
+
uncheck(options?: ElementClickOptions): Promise<void>;
|
|
1930
|
+
|
|
1931
|
+
/**
|
|
1932
|
+
* Checks to see if the `input type="checkbox"` is selected or not.
|
|
1933
|
+
* @param options Options to use.
|
|
1934
|
+
* @returns `true` if the element is checked, `false` otherwise.
|
|
1935
|
+
*/
|
|
1936
|
+
isChecked(options?: TimeoutOptions): Promise<boolean>;
|
|
1937
|
+
|
|
1938
|
+
/**
|
|
1939
|
+
* Checks if the element is editable.
|
|
1940
|
+
* @param options Options to use.
|
|
1941
|
+
* @returns `true` if the element is editable, `false` otherwise.
|
|
1942
|
+
*/
|
|
1943
|
+
isEditable(options?: TimeoutOptions): Promise<boolean>;
|
|
1944
|
+
|
|
1945
|
+
/**
|
|
1946
|
+
* Checks if the element is `enabled`.
|
|
1947
|
+
* @param options Options to use.
|
|
1948
|
+
* @returns `true` if the element is enabled, `false` otherwise.
|
|
1949
|
+
*/
|
|
1950
|
+
isEnabled(options?: TimeoutOptions): Promise<boolean>;
|
|
1951
|
+
|
|
1952
|
+
/**
|
|
1953
|
+
* Checks if the element is `disabled`.
|
|
1954
|
+
* @param options Options to use.
|
|
1955
|
+
* @returns `true` if the element is disabled, `false` otherwise.
|
|
1956
|
+
*/
|
|
1957
|
+
isDisabled(options?: TimeoutOptions): Promise<boolean>;
|
|
1958
|
+
|
|
1959
|
+
/**
|
|
1960
|
+
* Checks if the element is `visible`.
|
|
1961
|
+
* @returns `true` if the element is visible, `false` otherwise.
|
|
1962
|
+
*/
|
|
1963
|
+
isVisible(): Promise<boolean>;
|
|
1964
|
+
|
|
1965
|
+
/**
|
|
1966
|
+
* Checks if the element is `hidden`.
|
|
1967
|
+
* @returns `true` if the element is hidden, `false` otherwise.
|
|
1968
|
+
*/
|
|
1969
|
+
isHidden(): Promise<boolean>;
|
|
1970
|
+
|
|
1971
|
+
/**
|
|
1972
|
+
* Fill an `input`, `textarea` or `contenteditable` element with the provided value.
|
|
1973
|
+
* @param value Value to fill for the `input` or `textarea` element.
|
|
1974
|
+
* @param options Options to use.
|
|
1975
|
+
*/
|
|
1976
|
+
fill(value: string, options?: ElementHandleOptions): Promise<void>;
|
|
1977
|
+
|
|
1978
|
+
/**
|
|
1979
|
+
* Focuses the element using locator's selector.
|
|
1980
|
+
* @param options Options to use.
|
|
1981
|
+
*/
|
|
1982
|
+
focus(options?: TimeoutOptions): Promise<void>;
|
|
1983
|
+
|
|
1984
|
+
/**
|
|
1985
|
+
* Returns the element attribute value for the given attribute name.
|
|
1986
|
+
* @param name Attribute name to retrieve value for.
|
|
1987
|
+
* @param options Options to use.
|
|
1988
|
+
* @returns Attribute value.
|
|
1989
|
+
*/
|
|
1990
|
+
getAttribute(name: string, options?: TimeoutOptions): Promise<string | null>;
|
|
1991
|
+
|
|
1992
|
+
/**
|
|
1993
|
+
* Returns the `element.innerHTML`.
|
|
1994
|
+
* @param options Options to use.
|
|
1995
|
+
* @returns Element's innerHTML.
|
|
1996
|
+
*/
|
|
1997
|
+
innerHTML(options?: TimeoutOptions): Promise<string>;
|
|
1998
|
+
|
|
1999
|
+
/**
|
|
2000
|
+
* Returns the `element.innerText`.
|
|
2001
|
+
* @param options Options to use.
|
|
2002
|
+
* @returns Element's innerText.
|
|
2003
|
+
*/
|
|
2004
|
+
innerText(options?: TimeoutOptions): Promise<string>;
|
|
2005
|
+
|
|
2006
|
+
/**
|
|
2007
|
+
* Returns the `element.textContent`.
|
|
2008
|
+
* @param options Options to use.
|
|
2009
|
+
* @returns Element's textContent.
|
|
2010
|
+
*/
|
|
2011
|
+
textContent(options?: TimeoutOptions): Promise<string | null>;
|
|
2012
|
+
|
|
2013
|
+
/**
|
|
2014
|
+
* Returns `input.value` for the selected `input`, `textarea` or `select` element.
|
|
2015
|
+
* @param options Options to use.
|
|
2016
|
+
* @returns The input value of the element.
|
|
2017
|
+
*/
|
|
2018
|
+
inputValue(options?: TimeoutOptions): Promise<string>;
|
|
2019
|
+
|
|
2020
|
+
/**
|
|
2021
|
+
* Select one or more options which match the values. If the select has the multiple attribute, all matching options are selected,
|
|
2022
|
+
* otherwise only the first option matching one of the passed options is selected.
|
|
2023
|
+
* @param values Values of options to select.
|
|
2024
|
+
* @param options Options to use.
|
|
2025
|
+
* @returns List of selected options.
|
|
2026
|
+
*/
|
|
2027
|
+
selectOption(
|
|
2028
|
+
values: string | string[] | { value?: string; label?: string; index?: number },
|
|
2029
|
+
options?: ElementHandleOptions,
|
|
2030
|
+
): Promise<string[]>;
|
|
2031
|
+
|
|
2032
|
+
/**
|
|
2033
|
+
* Press a single key on the keyboard or a combination of keys.
|
|
2034
|
+
* A superset of the key values can be found [here](https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values).
|
|
2035
|
+
* @param key Name of the key to press or a character to generate, such as `ArrowLeft` or `a`.
|
|
2036
|
+
* @param options Keyboard press options.
|
|
2037
|
+
*/
|
|
2038
|
+
press(key: string, options?: KeyboardPressOptions): Promise<void>;
|
|
2039
|
+
|
|
2040
|
+
/**
|
|
2041
|
+
* Type a text into the input field.
|
|
2042
|
+
* @param text Text to type into the input field.
|
|
2043
|
+
* @param options Typing options.
|
|
2044
|
+
*/
|
|
2045
|
+
type(text: string, options?: KeyboardPressOptions): Promise<void>;
|
|
2046
|
+
|
|
2047
|
+
/**
|
|
2048
|
+
* Hover over the element.
|
|
2049
|
+
* @param options Options to use.
|
|
2050
|
+
*/
|
|
2051
|
+
hover(options?: MouseMoveOptions): Promise<void>;
|
|
2052
|
+
|
|
2053
|
+
/**
|
|
2054
|
+
* Tap on the chosen element.
|
|
2055
|
+
* @param options Options to use.
|
|
2056
|
+
*/
|
|
2057
|
+
tap(options?: MouseMoveOptions): Promise<void>;
|
|
2058
|
+
|
|
2059
|
+
/**
|
|
2060
|
+
* Dispatches HTML DOM event types e.g. `click`.
|
|
2061
|
+
* @param type DOM event type.
|
|
2062
|
+
* @param eventInit Event-specific properties.
|
|
2063
|
+
* @param options Options to use.
|
|
2064
|
+
*/
|
|
2065
|
+
dispatchEvent(type: string, eventInit?: EvaluationArgument, options?: TimeoutOptions): Promise<void>;
|
|
2066
|
+
|
|
2067
|
+
/**
|
|
2068
|
+
* Wait for the element to be in a particular state e.g. `visible`.
|
|
2069
|
+
* @param options Wait options.
|
|
2070
|
+
*/
|
|
2071
|
+
waitFor(options?: { state?: ElementState } & TimeoutOptions): Promise<void>;
|
|
2072
|
+
}
|
|
2073
|
+
|
|
2074
|
+
/**
|
|
2075
|
+
* Mouse provides an API for managing a virtual mouse.
|
|
2076
|
+
*/
|
|
2077
|
+
export interface Mouse {
|
|
2078
|
+
/**
|
|
2079
|
+
* Shortcut for `mouse.move(x, y)`, `mouse.down()`, `mouse.up()`.
|
|
2080
|
+
* @param x The x position.
|
|
2081
|
+
* @param y The y position.
|
|
2082
|
+
* @param options The click options.
|
|
2083
|
+
*/
|
|
2084
|
+
click(x: number, y: number, options?: MouseMultiClickOptions): Promise<void>;
|
|
2085
|
+
|
|
2086
|
+
/**
|
|
2087
|
+
* Shortcut for `mouse.move(x, y)`, `mouse.down()`, `mouse.up()`, `mouse.down()`,
|
|
2088
|
+
* `mouse.up()`.
|
|
2089
|
+
* @param x The x position.
|
|
2090
|
+
* @param y The y position.
|
|
2091
|
+
* @param options The click options.
|
|
2092
|
+
*/
|
|
2093
|
+
dblclick(x: number, y: number, options?: MouseClickOptions): Promise<void>;
|
|
2094
|
+
|
|
2095
|
+
/**
|
|
2096
|
+
* Dispatches a `mousedown` event.
|
|
2097
|
+
* @param options The mouse down options.
|
|
2098
|
+
*/
|
|
2099
|
+
down(options?: MouseDownUpOptions): Promise<void>;
|
|
2100
|
+
|
|
2101
|
+
/**
|
|
2102
|
+
* Dispatches a `mousemove` event.
|
|
2103
|
+
* @param x The x position.
|
|
2104
|
+
* @param y The y position.
|
|
2105
|
+
* @param options The mouse move options.
|
|
2106
|
+
*/
|
|
2107
|
+
move(x: number, y: number, options?: { steps?: number }): Promise<void>;
|
|
2108
|
+
|
|
2109
|
+
/**
|
|
2110
|
+
* Dispatches a `mouseup` event.
|
|
2111
|
+
* @param options The mouse up options.
|
|
2112
|
+
*/
|
|
2113
|
+
up(options?: MouseDownUpOptions): Promise<void>;
|
|
2114
|
+
}
|
|
2115
|
+
|
|
2116
|
+
/**
|
|
2117
|
+
* Page provides methods to interact with a single tab in a running web browser
|
|
2118
|
+
* instance. One instance of the browser can have many page instances.
|
|
2119
|
+
*/
|
|
2120
|
+
export interface Page {
|
|
2121
|
+
/**
|
|
2122
|
+
* Activates the browser tab so that it comes into focus and actions can be
|
|
2123
|
+
* performed against it.
|
|
2124
|
+
*/
|
|
2125
|
+
bringToFront(): Promise<void>;
|
|
2126
|
+
|
|
2127
|
+
/**
|
|
2128
|
+
* **NOTE** Use locator-based `locator.check([options])` instead.
|
|
2129
|
+
*
|
|
2130
|
+
* This method is used to select an input checkbox.
|
|
2131
|
+
* @param selector A selector to search for an element. If there are multiple
|
|
2132
|
+
* elements satisfying the selector, the first will be used.
|
|
2133
|
+
* @param options
|
|
2134
|
+
*/
|
|
2135
|
+
check(
|
|
2136
|
+
selector: string,
|
|
2137
|
+
options?: {
|
|
2138
|
+
/**
|
|
2139
|
+
* Setting this to `true` will bypass the actionability checks (visible,
|
|
2140
|
+
* stable, enabled). Defaults to `false`.
|
|
2141
|
+
*/
|
|
2142
|
+
force?: boolean;
|
|
2143
|
+
|
|
2144
|
+
/**
|
|
2145
|
+
* If set to `true` and a navigation occurs from performing this action, it
|
|
2146
|
+
* will not wait for it to complete. Defaults to `false`.
|
|
2147
|
+
*/
|
|
2148
|
+
noWaitAfter?: boolean;
|
|
2149
|
+
|
|
2150
|
+
/**
|
|
2151
|
+
* A point to use relative to the top left corner of the element. If not
|
|
2152
|
+
* supplied, a visible point of the element is used.
|
|
2153
|
+
*/
|
|
2154
|
+
position?: {
|
|
2155
|
+
x: number;
|
|
2156
|
+
|
|
2157
|
+
y: number;
|
|
2158
|
+
};
|
|
2159
|
+
|
|
2160
|
+
/**
|
|
2161
|
+
* When `true`, the call requires selector to resolve to a single element.
|
|
2162
|
+
* If given selector resolves to more than one element, the call throws
|
|
2163
|
+
* an exception. Defaults to `false`.
|
|
2164
|
+
*/
|
|
2165
|
+
strict?: boolean;
|
|
2166
|
+
|
|
2167
|
+
/**
|
|
2168
|
+
* Maximum time in milliseconds. Defaults to `30` seconds. Default is
|
|
2169
|
+
* overridden by the `setDefaultTimeout` option on `BrowserContext` or
|
|
2170
|
+
* `page` methods.
|
|
2171
|
+
*
|
|
2172
|
+
* Setting the value to `0` will disable the timeout.
|
|
2173
|
+
*/
|
|
2174
|
+
timeout?: number;
|
|
2175
|
+
|
|
2176
|
+
/**
|
|
2177
|
+
* Setting this to `true` will perform the actionability checks without
|
|
2178
|
+
* performing the action. Useful to wait until the element is ready for the
|
|
2179
|
+
* action without performing it. Defaults to `false`.
|
|
2180
|
+
*/
|
|
2181
|
+
trial?: boolean;
|
|
2182
|
+
},
|
|
2183
|
+
): Promise<void>;
|
|
2184
|
+
|
|
2185
|
+
/**
|
|
2186
|
+
* **NOTE** Use locator-based `locator.click([options])` instead.
|
|
2187
|
+
*
|
|
2188
|
+
* This method clicks an element matching `selector`.
|
|
2189
|
+
* @param selector A selector to search for an element. If there are multiple
|
|
2190
|
+
* elements satisfying the selector, the first will be used.
|
|
2191
|
+
* @param options
|
|
2192
|
+
*/
|
|
2193
|
+
click(
|
|
2194
|
+
selector: string,
|
|
2195
|
+
options?: {
|
|
2196
|
+
/**
|
|
2197
|
+
* The mouse button (`left`, `middle` or `right`) to use during the action.
|
|
2198
|
+
* Defaults to `left`.
|
|
2199
|
+
*/
|
|
2200
|
+
button?: MouseButton;
|
|
2201
|
+
|
|
2202
|
+
/**
|
|
2203
|
+
* The number of times the action is performed. Defaults to `1`.
|
|
2204
|
+
*/
|
|
2205
|
+
clickCount?: number;
|
|
2206
|
+
|
|
2207
|
+
/**
|
|
2208
|
+
* Milliseconds to wait between `mousedown` and `mouseup`. Defaults to `0`.
|
|
2209
|
+
*/
|
|
2210
|
+
delay?: number;
|
|
2211
|
+
|
|
2212
|
+
/**
|
|
2213
|
+
* Setting this to `true` will bypass the actionability checks (`visible`,
|
|
2214
|
+
* `stable`, `enabled`). Defaults to `false`.
|
|
2215
|
+
*/
|
|
2216
|
+
force?: boolean;
|
|
2217
|
+
|
|
2218
|
+
/**
|
|
2219
|
+
* `Alt`, `Control`, `Meta` or `Shift` modifiers keys pressed during the
|
|
2220
|
+
* action. If not specified, currently pressed modifiers are used,
|
|
2221
|
+
* otherwise defaults to `null`.
|
|
2222
|
+
*/
|
|
2223
|
+
modifiers?: KeyboardModifier[];
|
|
2224
|
+
|
|
2225
|
+
/**
|
|
2226
|
+
* If set to `true` and a navigation occurs from performing this action, it
|
|
2227
|
+
* will not wait for it to complete. Defaults to `false`.
|
|
2228
|
+
*/
|
|
2229
|
+
noWaitAfter?: boolean;
|
|
2230
|
+
|
|
2231
|
+
/**
|
|
2232
|
+
* A point to use relative to the top left corner of the element. If not
|
|
2233
|
+
* supplied, a visible point of the element is used.
|
|
2234
|
+
*/
|
|
2235
|
+
position?: {
|
|
2236
|
+
x: number;
|
|
2237
|
+
|
|
2238
|
+
y: number;
|
|
2239
|
+
};
|
|
2240
|
+
|
|
2241
|
+
/**
|
|
2242
|
+
* When `true`, the call requires selector to resolve to a single element.
|
|
2243
|
+
* If given selector resolves to more than one element, the call throws
|
|
2244
|
+
* an exception. Defaults to `false`.
|
|
2245
|
+
*/
|
|
2246
|
+
strict?: boolean;
|
|
2247
|
+
|
|
2248
|
+
/**
|
|
2249
|
+
* Maximum time in milliseconds. Defaults to `30` seconds. Default is
|
|
2250
|
+
* overridden by the `setDefaultTimeout` option on `BrowserContext` or
|
|
2251
|
+
* `page` methods.
|
|
2252
|
+
*
|
|
2253
|
+
* Setting the value to `0` will disable the timeout.
|
|
2254
|
+
*/
|
|
2255
|
+
timeout?: number;
|
|
2256
|
+
|
|
2257
|
+
/**
|
|
2258
|
+
* Setting this to `true` will perform the actionability checks without
|
|
2259
|
+
* performing the action. Useful to wait until the element is ready for the
|
|
2260
|
+
* action without performing it. Defaults to `false`.
|
|
2261
|
+
*/
|
|
2262
|
+
trial?: boolean;
|
|
2263
|
+
},
|
|
2264
|
+
): Promise<void>;
|
|
2265
|
+
|
|
2266
|
+
/**
|
|
2267
|
+
* This will close the tab that this page is associated with.
|
|
2268
|
+
*/
|
|
2269
|
+
close(): Promise<void>;
|
|
2270
|
+
|
|
2271
|
+
/**
|
|
2272
|
+
* Gets the HTML contents of the page.
|
|
2273
|
+
*/
|
|
2274
|
+
content(): Promise<string>;
|
|
2275
|
+
|
|
2276
|
+
/**
|
|
2277
|
+
* Gets the `BrowserContext` that the page belongs to.
|
|
2278
|
+
*/
|
|
2279
|
+
context(): BrowserContext;
|
|
2280
|
+
|
|
2281
|
+
/**
|
|
2282
|
+
* **NOTE** Use locator-based `locator.dblclick([options])` instead.
|
|
2283
|
+
*
|
|
2284
|
+
* Mouse double clicks an element matching provided selector.
|
|
2285
|
+
* @param selector A selector to search for an element. If there are multiple
|
|
2286
|
+
* elements satisfying the selector, the first will be used.
|
|
2287
|
+
* @param options
|
|
2288
|
+
*/
|
|
2289
|
+
dblclick(
|
|
2290
|
+
selector: string,
|
|
2291
|
+
options?: {
|
|
2292
|
+
/**
|
|
2293
|
+
* The mouse button (`left`, `middle` or `right`) to use during the action.
|
|
2294
|
+
* Defaults to `left`.
|
|
2295
|
+
*/
|
|
2296
|
+
button?: MouseButton;
|
|
2297
|
+
|
|
2298
|
+
/**
|
|
2299
|
+
* Milliseconds to wait between `mousedown` and `mouseup`. Defaults to `0`.
|
|
2300
|
+
*/
|
|
2301
|
+
delay?: number;
|
|
2302
|
+
|
|
2303
|
+
/**
|
|
2304
|
+
* Setting this to `true` will bypass the actionability checks (`visible`,
|
|
2305
|
+
* `stable`, `enabled`). Defaults to `false`.
|
|
2306
|
+
*/
|
|
2307
|
+
force?: boolean;
|
|
2308
|
+
|
|
2309
|
+
/**
|
|
2310
|
+
* `Alt`, `Control`, `Meta` or `Shift` modifiers keys pressed during the
|
|
2311
|
+
* action. If not specified, currently pressed modifiers are used,
|
|
2312
|
+
* otherwise defaults to `null`.
|
|
2313
|
+
*/
|
|
2314
|
+
modifiers?: KeyboardModifier[];
|
|
2315
|
+
|
|
2316
|
+
/**
|
|
2317
|
+
* If set to `true` and a navigation occurs from performing this action, it
|
|
2318
|
+
* will not wait for it to complete. Defaults to `false`.
|
|
2319
|
+
*/
|
|
2320
|
+
noWaitAfter?: boolean;
|
|
2321
|
+
|
|
2322
|
+
/**
|
|
2323
|
+
* A point to use relative to the top left corner of the element. If not
|
|
2324
|
+
* supplied, a visible point of the element is used.
|
|
2325
|
+
*/
|
|
2326
|
+
position?: {
|
|
2327
|
+
x: number;
|
|
2328
|
+
|
|
2329
|
+
y: number;
|
|
2330
|
+
};
|
|
2331
|
+
|
|
2332
|
+
/**
|
|
2333
|
+
* When `true`, the call requires selector to resolve to a single element.
|
|
2334
|
+
* If given selector resolves to more than one element, the call throws
|
|
2335
|
+
* an exception. Defaults to `false`.
|
|
2336
|
+
*/
|
|
2337
|
+
strict?: boolean;
|
|
2338
|
+
|
|
2339
|
+
/**
|
|
2340
|
+
* Maximum time in milliseconds. Defaults to `30` seconds. Default is
|
|
2341
|
+
* overridden by the `setDefaultTimeout` option on `BrowserContext` or
|
|
2342
|
+
* `page` methods.
|
|
2343
|
+
*
|
|
2344
|
+
* Setting the value to `0` will disable the timeout.
|
|
2345
|
+
*/
|
|
2346
|
+
timeout?: number;
|
|
2347
|
+
|
|
2348
|
+
/**
|
|
2349
|
+
* Setting this to `true` will perform the actionability checks without
|
|
2350
|
+
* performing the action. Useful to wait until the element is ready for the
|
|
2351
|
+
* action without performing it. Defaults to `false`.
|
|
2352
|
+
*/
|
|
2353
|
+
trial?: boolean;
|
|
2354
|
+
},
|
|
2355
|
+
): Promise<void>;
|
|
2356
|
+
|
|
2357
|
+
/**
|
|
2358
|
+
* **NOTE** Use locator-based locator.dispatchEvent([options]) instead.
|
|
2359
|
+
*
|
|
2360
|
+
* @param selector A selector to search for an element. If there are multiple
|
|
2361
|
+
* elements satisfying the selector, the first will be used.
|
|
2362
|
+
* @param type DOM event type: `"click"` etc.
|
|
2363
|
+
* @param eventInit Optional event-specific initialization properties.
|
|
2364
|
+
* @param options
|
|
2365
|
+
*/
|
|
2366
|
+
dispatchEvent(
|
|
2367
|
+
selector: string,
|
|
2368
|
+
type: string,
|
|
2369
|
+
eventInit?: EvaluationArgument,
|
|
2370
|
+
options?: {
|
|
2371
|
+
/**
|
|
2372
|
+
* When `true`, the call requires selector to resolve to a single element.
|
|
2373
|
+
* If given selector resolves to more than one element, the call throws
|
|
2374
|
+
* an exception. Defaults to `false`.
|
|
2375
|
+
*/
|
|
2376
|
+
strict?: boolean;
|
|
2377
|
+
|
|
2378
|
+
/**
|
|
2379
|
+
* Maximum time in milliseconds. Defaults to `30` seconds. Default is
|
|
2380
|
+
* overridden by the `setDefaultTimeout` option on `BrowserContext` or
|
|
2381
|
+
* `page` methods.
|
|
2382
|
+
*
|
|
2383
|
+
* Setting the value to `0` will disable the timeout.
|
|
2384
|
+
*/
|
|
2385
|
+
timeout?: number;
|
|
2386
|
+
},
|
|
2387
|
+
): Promise<void>;
|
|
2388
|
+
|
|
2389
|
+
/**
|
|
2390
|
+
* This method changes the `CSS media type` through the `media` argument,
|
|
2391
|
+
* and/or the `'prefers-colors-scheme'` media feature, using the `colorScheme`
|
|
2392
|
+
* argument.
|
|
2393
|
+
* @param options
|
|
2394
|
+
*/
|
|
2395
|
+
emulateMedia(options?: {
|
|
2396
|
+
/**
|
|
2397
|
+
* Emulates `'prefers-colors-scheme'` media feature, supported values are
|
|
2398
|
+
* `'light'`, `'dark'`, and `'no-preference'`.
|
|
2399
|
+
*/
|
|
2400
|
+
colorScheme?: "light" | "dark" | "no-preference";
|
|
2401
|
+
|
|
2402
|
+
/**
|
|
2403
|
+
* Changes the CSS media type of the page. The only allowed values are
|
|
2404
|
+
* `'screen'`, and `'print'`.
|
|
2405
|
+
*/
|
|
2406
|
+
media?: "screen" | "print";
|
|
2407
|
+
|
|
2408
|
+
/**
|
|
2409
|
+
* Emulates `'prefers-reduced-motion'` media feature, supported values are
|
|
2410
|
+
* `'reduce'`, `'no-preference'`.
|
|
2411
|
+
*/
|
|
2412
|
+
reducedMotion?: "reduce" | "no-preference";
|
|
2413
|
+
}): Promise<void>;
|
|
2414
|
+
|
|
2415
|
+
/**
|
|
2416
|
+
* This emulates your website with the specified vision deficiency type.
|
|
2417
|
+
* The supported types are:
|
|
2418
|
+
* - none: default.
|
|
2419
|
+
* - blurredVision: where vision is less precise.
|
|
2420
|
+
* - protanopia: the inability to perceive any red light.
|
|
2421
|
+
* - deuteranopia: the inability to perceive any green light.
|
|
2422
|
+
* - tritanopia: the inability to perceive any blue light.
|
|
2423
|
+
* - achromatopsia: the inability to perceive any color except for shades of
|
|
2424
|
+
* grey (extremely rare).
|
|
2425
|
+
* @param type
|
|
2426
|
+
*/
|
|
2427
|
+
emulateVisionDeficiency(
|
|
2428
|
+
type: "none" | "blurredVision" | "deuteranopia" | "protanopia" | "tritanopia" | "achromatopsia",
|
|
2429
|
+
): Promise<void>;
|
|
2430
|
+
|
|
2431
|
+
/**
|
|
2432
|
+
* Returns the value of the `pageFunction` invocation.
|
|
2433
|
+
*
|
|
2434
|
+
* A string can also be passed in instead of a function.
|
|
2435
|
+
*
|
|
2436
|
+
* @param pageFunction Function to be evaluated in the page context.
|
|
2437
|
+
* @param arg Optional argument to pass to `pageFunction`.
|
|
2438
|
+
*/
|
|
2439
|
+
evaluate<R, Arg>(pageFunction: PageFunction<Arg, R>, arg?: Arg): Promise<R>;
|
|
2440
|
+
|
|
2441
|
+
/**
|
|
2442
|
+
* Returns the value of the `pageFunction` invocation as a [JSHandle].
|
|
2443
|
+
*
|
|
2444
|
+
* The only difference between page.evaluate(pageFunction[, arg]) and
|
|
2445
|
+
* page.evaluateHandle(pageFunction[, arg]) is that
|
|
2446
|
+
* page.evaluateHandle(pageFunction[, arg])returns [JSHandle].
|
|
2447
|
+
*
|
|
2448
|
+
* @param pageFunction Function to be evaluated in the page context.
|
|
2449
|
+
* @param arg Optional argument to pass to `pageFunction`.
|
|
2450
|
+
*/
|
|
2451
|
+
evaluateHandle<R, Arg>(pageFunction: PageFunction<Arg, R>, arg?: Arg): Promise<JSHandle<R>>;
|
|
2452
|
+
|
|
2453
|
+
/**
|
|
2454
|
+
* **NOTE** Use locator-based `locator.fill(value[, options])` instead.
|
|
2455
|
+
*
|
|
2456
|
+
* Fill an `input`, `textarea` or `[contenteditable]` element with the
|
|
2457
|
+
* provided value.
|
|
2458
|
+
*
|
|
2459
|
+
* @param selector A selector to search for an element. If there are multiple
|
|
2460
|
+
* elements satisfying the selector, the first will be used.
|
|
2461
|
+
* @param value Value to fill for the `<input>`, `<textarea>` or
|
|
2462
|
+
* `[contenteditable]` element.
|
|
2463
|
+
* @param options
|
|
2464
|
+
*/
|
|
2465
|
+
fill(
|
|
2466
|
+
selector: string,
|
|
2467
|
+
value: string,
|
|
2468
|
+
options?: {
|
|
2469
|
+
/**
|
|
2470
|
+
* Setting this to `true` will bypass the actionability checks (`visible`,
|
|
2471
|
+
* `stable`, `enabled`). Defaults to `false`.
|
|
2472
|
+
*/
|
|
2473
|
+
force?: boolean;
|
|
2474
|
+
|
|
2475
|
+
/**
|
|
2476
|
+
* If set to `true` and a navigation occurs from performing this action, it
|
|
2477
|
+
* will not wait for it to complete. Defaults to `false`.
|
|
2478
|
+
*/
|
|
2479
|
+
noWaitAfter?: boolean;
|
|
2480
|
+
|
|
2481
|
+
/**
|
|
2482
|
+
* When `true`, the call requires selector to resolve to a single element.
|
|
2483
|
+
* If given selector resolves to more than one element, the call throws
|
|
2484
|
+
* an exception. Defaults to `false`.
|
|
2485
|
+
*/
|
|
2486
|
+
strict?: boolean;
|
|
2487
|
+
|
|
2488
|
+
/**
|
|
2489
|
+
* Maximum time in milliseconds. Defaults to `30` seconds. Default is
|
|
2490
|
+
* overridden by the `setDefaultTimeout` option on `BrowserContext` or
|
|
2491
|
+
* `page` methods.
|
|
2492
|
+
*
|
|
2493
|
+
* Setting the value to `0` will disable the timeout.
|
|
2494
|
+
*/
|
|
2495
|
+
timeout?: number;
|
|
2496
|
+
},
|
|
2497
|
+
): Promise<void>;
|
|
2498
|
+
|
|
2499
|
+
/**
|
|
2500
|
+
* **NOTE** Use locator-based `locator.focus([options])` instead.
|
|
2501
|
+
*
|
|
2502
|
+
* This method fetches an element with `selector` and focuses it.
|
|
2503
|
+
*
|
|
2504
|
+
* @param selector A selector to search for an element. If there are multiple
|
|
2505
|
+
* elements satisfying the selector, the first will be used.
|
|
2506
|
+
* @param options
|
|
2507
|
+
*/
|
|
2508
|
+
focus(
|
|
2509
|
+
selector: string,
|
|
2510
|
+
options?: {
|
|
2511
|
+
/**
|
|
2512
|
+
* When `true`, the call requires selector to resolve to a single element.
|
|
2513
|
+
* If given selector resolves to more than one element, the call throws
|
|
2514
|
+
* an exception. Defaults to `false`.
|
|
2515
|
+
*/
|
|
2516
|
+
strict?: boolean;
|
|
2517
|
+
|
|
2518
|
+
/**
|
|
2519
|
+
* Maximum time in milliseconds. Defaults to `30` seconds. Default is
|
|
2520
|
+
* overridden by the `setDefaultTimeout` option on `BrowserContext` or
|
|
2521
|
+
* `page` methods.
|
|
2522
|
+
*
|
|
2523
|
+
* Setting the value to `0` will disable the timeout.
|
|
2524
|
+
*/
|
|
2525
|
+
timeout?: number;
|
|
2526
|
+
},
|
|
2527
|
+
): Promise<void>;
|
|
2528
|
+
|
|
2529
|
+
/**
|
|
2530
|
+
* Frames returns an array of frames on the page.
|
|
2531
|
+
*/
|
|
2532
|
+
frames(): Frame[];
|
|
2533
|
+
|
|
2534
|
+
/**
|
|
2535
|
+
* **NOTE** Use locator-based locator.getAttribute(name[, options]) instead.
|
|
2536
|
+
*
|
|
2537
|
+
* Returns the element attribute value for the given attribute name.
|
|
2538
|
+
*
|
|
2539
|
+
* @param selector A selector to search for an element. If there are multiple
|
|
2540
|
+
* elements satisfying the selector, the first will be used.
|
|
2541
|
+
* @param name Attribute name to get the value for.
|
|
2542
|
+
* @param options
|
|
2543
|
+
*/
|
|
2544
|
+
getAttribute(
|
|
2545
|
+
selector: string,
|
|
2546
|
+
name: string,
|
|
2547
|
+
options?: {
|
|
2548
|
+
/**
|
|
2549
|
+
* When `true`, the call requires selector to resolve to a single element.
|
|
2550
|
+
* If given selector resolves to more than one element, the call throws
|
|
2551
|
+
* an exception. Defaults to `false`.
|
|
2552
|
+
*/
|
|
2553
|
+
strict?: boolean;
|
|
2554
|
+
|
|
2555
|
+
/**
|
|
2556
|
+
* Maximum time in milliseconds. Defaults to `30` seconds. Default is
|
|
2557
|
+
* overridden by the `setDefaultTimeout` option on `BrowserContext` or
|
|
2558
|
+
* `page` methods.
|
|
2559
|
+
*
|
|
2560
|
+
* Setting the value to `0` will disable the timeout.
|
|
2561
|
+
*/
|
|
2562
|
+
timeout?: number;
|
|
2563
|
+
},
|
|
2564
|
+
): Promise<string | null>;
|
|
2565
|
+
|
|
2566
|
+
/**
|
|
2567
|
+
* Navigates to the specified url and returns the main resource response.
|
|
2568
|
+
*
|
|
2569
|
+
* navigating to `about:blank` or navigation to the same URL with a different
|
|
2570
|
+
* hash, will succeed and return `null`.
|
|
2571
|
+
*
|
|
2572
|
+
* @param url URL to navigate page to. The url should include scheme, e.g.
|
|
2573
|
+
* `https://`.
|
|
2574
|
+
* @param options
|
|
2575
|
+
*/
|
|
2576
|
+
goto(url: string, options?: NavigationOptions): Promise<Response | null>;
|
|
2577
|
+
|
|
2578
|
+
/**
|
|
2579
|
+
* **NOTE** Use locator-based locator.hover([options]) instead.
|
|
2580
|
+
*
|
|
2581
|
+
* This method hovers over an element matching `selector`.
|
|
2582
|
+
*
|
|
2583
|
+
* @param selector A selector to search for an element. If there are multiple
|
|
2584
|
+
* elements satisfying the selector, the first will be used.
|
|
2585
|
+
* @param options
|
|
2586
|
+
*/
|
|
2587
|
+
hover(
|
|
2588
|
+
selector: string,
|
|
2589
|
+
options?: {
|
|
2590
|
+
/**
|
|
2591
|
+
* Setting this to `true` will bypass the actionability checks (`visible`,
|
|
2592
|
+
* `stable`, `enabled`). Defaults to `false`.
|
|
2593
|
+
*/
|
|
2594
|
+
force?: boolean;
|
|
2595
|
+
|
|
2596
|
+
/**
|
|
2597
|
+
* `Alt`, `Control`, `Meta` or `Shift` modifiers keys pressed during the
|
|
2598
|
+
* action. If not specified, currently pressed modifiers are used,
|
|
2599
|
+
* otherwise defaults to `null`.
|
|
2600
|
+
*/
|
|
2601
|
+
modifiers?: KeyboardModifier[];
|
|
2602
|
+
|
|
2603
|
+
/**
|
|
2604
|
+
* If set to `true` and a navigation occurs from performing this action, it
|
|
2605
|
+
* will not wait for it to complete. Defaults to `false`.
|
|
2606
|
+
*/
|
|
2607
|
+
noWaitAfter?: boolean;
|
|
2608
|
+
|
|
2609
|
+
/**
|
|
2610
|
+
* A point to use relative to the top left corner of the element. If not
|
|
2611
|
+
* supplied, a visible point of the element is used.
|
|
2612
|
+
*/
|
|
2613
|
+
position?: {
|
|
2614
|
+
x: number;
|
|
2615
|
+
|
|
2616
|
+
y: number;
|
|
2617
|
+
};
|
|
2618
|
+
|
|
2619
|
+
/**
|
|
2620
|
+
* When `true`, the call requires selector to resolve to a single element.
|
|
2621
|
+
* If given selector resolves to more than one element, the call throws
|
|
2622
|
+
* an exception. Defaults to `false`.
|
|
2623
|
+
*/
|
|
2624
|
+
strict?: boolean;
|
|
2625
|
+
|
|
2626
|
+
/**
|
|
2627
|
+
* Maximum time in milliseconds. Defaults to `30` seconds. Default is
|
|
2628
|
+
* overridden by the `setDefaultTimeout` option on `BrowserContext` or
|
|
2629
|
+
* `page` methods.
|
|
2630
|
+
*
|
|
2631
|
+
* Setting the value to `0` will disable the timeout.
|
|
2632
|
+
*/
|
|
2633
|
+
timeout?: number;
|
|
2634
|
+
|
|
2635
|
+
/**
|
|
2636
|
+
* Setting this to `true` will perform the actionability checks without
|
|
2637
|
+
* performing the action. Useful to wait until the element is ready for the
|
|
2638
|
+
* action without performing it. Defaults to `false`.
|
|
2639
|
+
*/
|
|
2640
|
+
trial?: boolean;
|
|
2641
|
+
},
|
|
2642
|
+
): Promise<void>;
|
|
2643
|
+
|
|
2644
|
+
/**
|
|
2645
|
+
* **NOTE** Use locator-based locator.innerHTML([options]) instead.
|
|
2646
|
+
*
|
|
2647
|
+
* Returns `element.innerHTML`.
|
|
2648
|
+
*
|
|
2649
|
+
* @param selector A selector to search for an element. If there are multiple
|
|
2650
|
+
* elements satisfying the selector, the first will be used.
|
|
2651
|
+
* @param options
|
|
2652
|
+
*/
|
|
2653
|
+
innerHTML(
|
|
2654
|
+
selector: string,
|
|
2655
|
+
options?: {
|
|
2656
|
+
/**
|
|
2657
|
+
* When `true`, the call requires selector to resolve to a single element.
|
|
2658
|
+
* If given selector resolves to more than one element, the call throws
|
|
2659
|
+
* an exception. Defaults to `false`.
|
|
2660
|
+
*/
|
|
2661
|
+
strict?: boolean;
|
|
2662
|
+
|
|
2663
|
+
/**
|
|
2664
|
+
* Maximum time in milliseconds. Defaults to `30` seconds. Default is
|
|
2665
|
+
* overridden by the `setDefaultTimeout` option on `BrowserContext` or
|
|
2666
|
+
* `page` methods.
|
|
2667
|
+
*
|
|
2668
|
+
* Setting the value to `0` will disable the timeout.
|
|
2669
|
+
*/
|
|
2670
|
+
timeout?: number;
|
|
2671
|
+
},
|
|
2672
|
+
): Promise<string>;
|
|
2673
|
+
|
|
2674
|
+
/**
|
|
2675
|
+
* **NOTE** Use locator-based locator.innerText([options]) instead.
|
|
2676
|
+
*
|
|
2677
|
+
* Returns `element.innerText`.
|
|
2678
|
+
*
|
|
2679
|
+
* @param selector A selector to search for an element. If there are multiple
|
|
2680
|
+
* elements satisfying the selector, the first will be used.
|
|
2681
|
+
* @param options
|
|
2682
|
+
*/
|
|
2683
|
+
innerText(
|
|
2684
|
+
selector: string,
|
|
2685
|
+
options?: {
|
|
2686
|
+
/**
|
|
2687
|
+
* When `true`, the call requires selector to resolve to a single element.
|
|
2688
|
+
* If given selector resolves to more than one element, the call throws
|
|
2689
|
+
* an exception. Defaults to `false`.
|
|
2690
|
+
*/
|
|
2691
|
+
strict?: boolean;
|
|
2692
|
+
|
|
2693
|
+
/**
|
|
2694
|
+
* Maximum time in milliseconds. Defaults to `30` seconds. Default is
|
|
2695
|
+
* overridden by the `setDefaultTimeout` option on `BrowserContext` or
|
|
2696
|
+
* `page` methods.
|
|
2697
|
+
*
|
|
2698
|
+
* Setting the value to `0` will disable the timeout.
|
|
2699
|
+
*/
|
|
2700
|
+
timeout?: number;
|
|
2701
|
+
},
|
|
2702
|
+
): Promise<string>;
|
|
2703
|
+
|
|
2704
|
+
/**
|
|
2705
|
+
* **NOTE** Use locator-based locator.inputValue([options]) instead.
|
|
2706
|
+
*
|
|
2707
|
+
* Returns `input.value` for the selected `<input>` or `<textarea>` or
|
|
2708
|
+
* `<select>` element.
|
|
2709
|
+
*
|
|
2710
|
+
* @param selector A selector to search for an element. If there are multiple
|
|
2711
|
+
* elements satisfying the selector, the first will be used.
|
|
2712
|
+
* @param options
|
|
2713
|
+
*/
|
|
2714
|
+
inputValue(
|
|
2715
|
+
selector: string,
|
|
2716
|
+
options?: {
|
|
2717
|
+
/**
|
|
2718
|
+
* When `true`, the call requires selector to resolve to a single element.
|
|
2719
|
+
* If given selector resolves to more than one element, the call throws
|
|
2720
|
+
* an exception. Defaults to `false`.
|
|
2721
|
+
*/
|
|
2722
|
+
strict?: boolean;
|
|
2723
|
+
|
|
2724
|
+
/**
|
|
2725
|
+
* Maximum time in milliseconds. Defaults to `30` seconds. Default is
|
|
2726
|
+
* overridden by the `setDefaultTimeout` option on `BrowserContext` or
|
|
2727
|
+
* `page` methods.
|
|
2728
|
+
*
|
|
2729
|
+
* Setting the value to `0` will disable the timeout.
|
|
2730
|
+
*/
|
|
2731
|
+
timeout?: number;
|
|
2732
|
+
},
|
|
2733
|
+
): Promise<string>;
|
|
2734
|
+
|
|
2735
|
+
/**
|
|
2736
|
+
* **NOTE** Use locator-based locator.isChecked([options]) instead.
|
|
2737
|
+
*
|
|
2738
|
+
* Checks to see if the `checkbox` `input` type is selected or not.
|
|
2739
|
+
*
|
|
2740
|
+
* @param selector A selector to search for an element. If there are multiple
|
|
2741
|
+
* elements satisfying the selector, the first will be used.
|
|
2742
|
+
* @param options
|
|
2743
|
+
*/
|
|
2744
|
+
isChecked(
|
|
2745
|
+
selector: string,
|
|
2746
|
+
options?: {
|
|
2747
|
+
/**
|
|
2748
|
+
* When `true`, the call requires selector to resolve to a single element.
|
|
2749
|
+
* If given selector resolves to more than one element, the call throws
|
|
2750
|
+
* an exception. Defaults to `false`.
|
|
2751
|
+
*/
|
|
2752
|
+
strict?: boolean;
|
|
2753
|
+
|
|
2754
|
+
/**
|
|
2755
|
+
* Maximum time in milliseconds. Defaults to `30` seconds. Default is
|
|
2756
|
+
* overridden by the `setDefaultTimeout` option on `BrowserContext` or
|
|
2757
|
+
* `page` methods.
|
|
2758
|
+
*
|
|
2759
|
+
* Setting the value to `0` will disable the timeout.
|
|
2760
|
+
*/
|
|
2761
|
+
timeout?: number;
|
|
2762
|
+
},
|
|
2763
|
+
): Promise<boolean>;
|
|
2764
|
+
|
|
2765
|
+
/**
|
|
2766
|
+
* Indicates that the page has been closed.
|
|
2767
|
+
*/
|
|
2768
|
+
isClosed(): boolean;
|
|
2769
|
+
|
|
2770
|
+
/**
|
|
2771
|
+
* **NOTE** Use locator-based locator.isDisabled([options]) instead.
|
|
2772
|
+
*
|
|
2773
|
+
* Returns whether the element is disabled.
|
|
2774
|
+
*
|
|
2775
|
+
* @param selector A selector to search for an element. If there are multiple
|
|
2776
|
+
* elements satisfying the selector, the first will be used.
|
|
2777
|
+
* @param options
|
|
2778
|
+
*/
|
|
2779
|
+
isDisabled(
|
|
2780
|
+
selector: string,
|
|
2781
|
+
options?: {
|
|
2782
|
+
/**
|
|
2783
|
+
* When `true`, the call requires selector to resolve to a single element.
|
|
2784
|
+
* If given selector resolves to more than one element, the call throws
|
|
2785
|
+
* an exception. Defaults to `false`.
|
|
2786
|
+
*/
|
|
2787
|
+
strict?: boolean;
|
|
2788
|
+
|
|
2789
|
+
/**
|
|
2790
|
+
* Maximum time in milliseconds. Defaults to `30` seconds. Default is
|
|
2791
|
+
* overridden by the `setDefaultTimeout` option on `BrowserContext` or
|
|
2792
|
+
* `page` methods.
|
|
2793
|
+
*
|
|
2794
|
+
* Setting the value to `0` will disable the timeout.
|
|
2795
|
+
*/
|
|
2796
|
+
timeout?: number;
|
|
2797
|
+
},
|
|
2798
|
+
): Promise<boolean>;
|
|
2799
|
+
|
|
2800
|
+
/**
|
|
2801
|
+
* **NOTE** Use locator-based locator.isEditable([options]) instead.
|
|
2802
|
+
*
|
|
2803
|
+
* Returns whether the element is editable.
|
|
2804
|
+
*
|
|
2805
|
+
* @param selector A selector to search for an element. If there are multiple
|
|
2806
|
+
* elements satisfying the selector, the first will be used.
|
|
2807
|
+
* @param options
|
|
2808
|
+
*/
|
|
2809
|
+
isEditable(
|
|
2810
|
+
selector: string,
|
|
2811
|
+
options?: {
|
|
2812
|
+
/**
|
|
2813
|
+
* When `true`, the call requires selector to resolve to a single element.
|
|
2814
|
+
* If given selector resolves to more than one element, the call throws
|
|
2815
|
+
* an exception. Defaults to `false`.
|
|
2816
|
+
*/
|
|
2817
|
+
strict?: boolean;
|
|
2818
|
+
|
|
2819
|
+
/**
|
|
2820
|
+
* Maximum time in milliseconds. Defaults to `30` seconds. Default is
|
|
2821
|
+
* overridden by the `setDefaultTimeout` option on `BrowserContext` or
|
|
2822
|
+
* `page` methods.
|
|
2823
|
+
*
|
|
2824
|
+
* Setting the value to `0` will disable the timeout.
|
|
2825
|
+
*/
|
|
2826
|
+
timeout?: number;
|
|
2827
|
+
},
|
|
2828
|
+
): Promise<boolean>;
|
|
2829
|
+
|
|
2830
|
+
/**
|
|
2831
|
+
* **NOTE** Use locator-based locator.isEnabled([options]) instead.
|
|
2832
|
+
*
|
|
2833
|
+
* Returns whether the element is enabled.
|
|
2834
|
+
*
|
|
2835
|
+
* @param selector A selector to search for an element. If there are multiple
|
|
2836
|
+
* elements satisfying the selector, the first will be used.
|
|
2837
|
+
* @param options
|
|
2838
|
+
*/
|
|
2839
|
+
isEnabled(
|
|
2840
|
+
selector: string,
|
|
2841
|
+
options?: {
|
|
2842
|
+
/**
|
|
2843
|
+
* When `true`, the call requires selector to resolve to a single element.
|
|
2844
|
+
* If given selector resolves to more than one element, the call throws
|
|
2845
|
+
* an exception. Defaults to `false`.
|
|
2846
|
+
*/
|
|
2847
|
+
strict?: boolean;
|
|
2848
|
+
|
|
2849
|
+
/**
|
|
2850
|
+
* Maximum time in milliseconds. Defaults to `30` seconds. Default is
|
|
2851
|
+
* overridden by the `setDefaultTimeout` option on `BrowserContext` or
|
|
2852
|
+
* `page` methods.
|
|
2853
|
+
*
|
|
2854
|
+
* Setting the value to `0` will disable the timeout.
|
|
2855
|
+
*/
|
|
2856
|
+
timeout?: number;
|
|
2857
|
+
},
|
|
2858
|
+
): Promise<boolean>;
|
|
2859
|
+
|
|
2860
|
+
/**
|
|
2861
|
+
* **NOTE** Use locator-based locator.isHidden() instead.
|
|
2862
|
+
*
|
|
2863
|
+
* Returns whether the element is hidden.
|
|
2864
|
+
*
|
|
2865
|
+
* @param selector A selector to search for an element. If there are multiple
|
|
2866
|
+
* elements satisfying the selector, the first will be used.
|
|
2867
|
+
* @param options
|
|
2868
|
+
*/
|
|
2869
|
+
isHidden(selector: string, options?: StrictnessOptions): Promise<boolean>;
|
|
2870
|
+
|
|
2871
|
+
/**
|
|
2872
|
+
* **NOTE** Use locator-based locator.isVisible() instead.
|
|
2873
|
+
*
|
|
2874
|
+
* Returns whether the element is visible.
|
|
2875
|
+
*
|
|
2876
|
+
* @param selector A selector to search for an element. If there are multiple
|
|
2877
|
+
* elements satisfying the selector, the first will be used.
|
|
2878
|
+
* @param options
|
|
2879
|
+
*/
|
|
2880
|
+
isVisible(selector: string, options?: StrictnessOptions): Promise<boolean>;
|
|
2881
|
+
|
|
2882
|
+
/**
|
|
2883
|
+
* Returns the keyboard instance to interact with a virtual keyboard on the
|
|
2884
|
+
* page.
|
|
2885
|
+
*/
|
|
2886
|
+
keyboard: Keyboard;
|
|
2887
|
+
|
|
2888
|
+
/**
|
|
2889
|
+
* The method returns an element locator. Locators resolve to the element
|
|
2890
|
+
* when the action takes place, which means locators can span over navigations
|
|
2891
|
+
* where the underlying dom changes.
|
|
2892
|
+
*
|
|
2893
|
+
* @param selector A selector to use when resolving DOM element.
|
|
2894
|
+
*/
|
|
2895
|
+
locator(selector: string): Locator;
|
|
2896
|
+
|
|
2897
|
+
/**
|
|
2898
|
+
* The page's main frame. Page is made up of frames in a hierarchical. At the
|
|
2899
|
+
* top is mainFrame. A page is guaranteed to have a mainFrame.
|
|
2900
|
+
*/
|
|
2901
|
+
mainFrame(): Frame;
|
|
2902
|
+
|
|
2903
|
+
/**
|
|
2904
|
+
* Returns the mouse instance to interact with a virtual mouse on the page.
|
|
2905
|
+
*/
|
|
2906
|
+
mouse: Mouse;
|
|
2907
|
+
|
|
2908
|
+
/**
|
|
2909
|
+
* Emitted when JavaScript within the page calls one of console API methods
|
|
2910
|
+
* , e.g. `console.log` or `console.dir`. Also emitted if the page throws
|
|
2911
|
+
* an error or a warning.
|
|
2912
|
+
*
|
|
2913
|
+
* The arguments passed into `console.log` are available on the
|
|
2914
|
+
* {@link ConsoleMessage} event handler argument.
|
|
2915
|
+
*
|
|
2916
|
+
* **Usage**
|
|
2917
|
+
*
|
|
2918
|
+
* ```js
|
|
2919
|
+
* page.on('console', msg => {
|
|
2920
|
+
* const values = [];
|
|
2921
|
+
* for (const arg of msg.args())
|
|
2922
|
+
* values.push(arg.jsonValue());
|
|
2923
|
+
* console.log(...values);
|
|
2924
|
+
* });
|
|
2925
|
+
* page.evaluate(() => console.log('hello', 5, { foo: 'bar' }));
|
|
2926
|
+
* ```
|
|
2927
|
+
*/
|
|
2928
|
+
on(event: "console", listener: (consoleMessage: ConsoleMessage) => void): void;
|
|
2929
|
+
|
|
2930
|
+
/**
|
|
2931
|
+
* Returns the page that opened the current page. The first page that is
|
|
2932
|
+
* navigated to will have a null opener.
|
|
2933
|
+
*/
|
|
2934
|
+
opener(): Promise<Page | null>;
|
|
2935
|
+
|
|
2936
|
+
/**
|
|
2937
|
+
* **NOTE** Use locator-based locator.press(key[, options]) instead.
|
|
2938
|
+
*
|
|
2939
|
+
* Focuses the element, and then uses keyboard.down(key) and
|
|
2940
|
+
* keyboard.up(key).
|
|
2941
|
+
*
|
|
2942
|
+
* A superset of the `key` values can be found [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values).
|
|
2943
|
+
*
|
|
2944
|
+
* Following modification shortcuts are also supported: `Shift`, `Control`,
|
|
2945
|
+
* `Alt`, `Meta`, `ShiftLeft`.
|
|
2946
|
+
*
|
|
2947
|
+
* Holding down `Shift` will type the text that corresponds to the `key` in
|
|
2948
|
+
* the upper case.
|
|
2949
|
+
*
|
|
2950
|
+
* If `key` is a single character, it is case-sensitive, so the values `a`
|
|
2951
|
+
* and `A` will generate different respective texts.
|
|
2952
|
+
*
|
|
2953
|
+
* Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are
|
|
2954
|
+
* supported as well. When specified with the modifier, modifier is pressed
|
|
2955
|
+
* and being held while the subsequent key is being pressed.
|
|
2956
|
+
*
|
|
2957
|
+
* @param selector A selector to search for an element. If there are multiple
|
|
2958
|
+
* elements satisfying the selector, the first will be used.
|
|
2959
|
+
* @param key Name of the key to press or a character to generate, such as
|
|
2960
|
+
* `ArrowLeft` or `a`.
|
|
2961
|
+
* @param options
|
|
2962
|
+
*/
|
|
2963
|
+
press(
|
|
2964
|
+
selector: string,
|
|
2965
|
+
key: string,
|
|
2966
|
+
options?: {
|
|
2967
|
+
/**
|
|
2968
|
+
* Milliseconds to wait between `mousedown` and `mouseup`. Defaults to `0`.
|
|
2969
|
+
*/
|
|
2970
|
+
delay?: number;
|
|
2971
|
+
|
|
2972
|
+
/**
|
|
2973
|
+
* If set to `true` and a navigation occurs from performing this action, it
|
|
2974
|
+
* will not wait for it to complete. Defaults to `false`.
|
|
2975
|
+
*/
|
|
2976
|
+
noWaitAfter?: boolean;
|
|
2977
|
+
|
|
2978
|
+
/**
|
|
2979
|
+
* When `true`, the call requires selector to resolve to a single element.
|
|
2980
|
+
* If given selector resolves to more than one element, the call throws
|
|
2981
|
+
* an exception. Defaults to `false`.
|
|
2982
|
+
*/
|
|
2983
|
+
strict?: boolean;
|
|
2984
|
+
|
|
2985
|
+
/**
|
|
2986
|
+
* Maximum time in milliseconds. Defaults to `30` seconds. Default is
|
|
2987
|
+
* overridden by the `setDefaultTimeout` option on `BrowserContext` or
|
|
2988
|
+
* `page` methods.
|
|
2989
|
+
*
|
|
2990
|
+
* Setting the value to `0` will disable the timeout.
|
|
2991
|
+
*/
|
|
2992
|
+
timeout?: number;
|
|
2993
|
+
},
|
|
2994
|
+
): Promise<void>;
|
|
2995
|
+
|
|
2996
|
+
/**
|
|
2997
|
+
* This reloads the current page Returns the main resource response.
|
|
2998
|
+
*
|
|
2999
|
+
* @param options
|
|
3000
|
+
*/
|
|
3001
|
+
reload(options?: {
|
|
3002
|
+
/**
|
|
3003
|
+
* Maximum operation time in milliseconds. Defaults to `30` seconds. The
|
|
3004
|
+
* default value can be changed via the
|
|
3005
|
+
* browserContext.setDefaultNavigationTimeout(timeout),
|
|
3006
|
+
* browserContext.setDefaultTimeout(timeout),
|
|
3007
|
+
* page.setDefaultNavigationTimeout(timeout) or
|
|
3008
|
+
* page.setDefaultTimeout(timeout) methods.
|
|
3009
|
+
*
|
|
3010
|
+
* Setting the value to `0` will disable the timeout.
|
|
3011
|
+
*/
|
|
3012
|
+
timeout?: number;
|
|
3013
|
+
|
|
3014
|
+
/**
|
|
3015
|
+
* When to consider operation succeeded, defaults to `load`. Events can be
|
|
3016
|
+
* either:
|
|
3017
|
+
* - `'domcontentloaded'` - consider operation to be finished when the
|
|
3018
|
+
* `DOMContentLoaded` event is fired.
|
|
3019
|
+
* - `'load'` - consider operation to be finished when the `load` event is
|
|
3020
|
+
* fired.
|
|
3021
|
+
* - `'networkidle'` - **DISCOURAGED** consider operation to be finished
|
|
3022
|
+
* when there are no network connections for at least `500` ms. Don't use
|
|
3023
|
+
* this method for testing especially with chatty websites where the event
|
|
3024
|
+
* may never fire, rely on web assertions to assess readiness instead.
|
|
3025
|
+
*/
|
|
3026
|
+
waitUntil?: "load" | "domcontentloaded" | "networkidle";
|
|
3027
|
+
}): Promise<Response | null>;
|
|
3028
|
+
|
|
3029
|
+
/**
|
|
3030
|
+
* Returns the buffer with the captured screenshot from the browser.
|
|
3031
|
+
*
|
|
3032
|
+
* @param options
|
|
3033
|
+
*/
|
|
3034
|
+
screenshot(
|
|
3035
|
+
options?: {
|
|
3036
|
+
/**
|
|
3037
|
+
* An object which specifies clipping of the resulting image.
|
|
3038
|
+
*/
|
|
3039
|
+
clip?: {
|
|
3040
|
+
/**
|
|
3041
|
+
* x-coordinate of top-left corner of clip area
|
|
3042
|
+
*/
|
|
3043
|
+
x: number;
|
|
3044
|
+
|
|
3045
|
+
/**
|
|
3046
|
+
* y-coordinate of top-left corner of clip area
|
|
3047
|
+
*/
|
|
3048
|
+
y: number;
|
|
3049
|
+
|
|
3050
|
+
/**
|
|
3051
|
+
* width of clipping area
|
|
3052
|
+
*/
|
|
3053
|
+
width: number;
|
|
3054
|
+
|
|
3055
|
+
/**
|
|
3056
|
+
* height of clipping area
|
|
3057
|
+
*/
|
|
3058
|
+
height: number;
|
|
3059
|
+
};
|
|
3060
|
+
|
|
3061
|
+
/**
|
|
3062
|
+
* When true, takes a screenshot of the full scrollable page, instead of
|
|
3063
|
+
* the currently visible viewport. Defaults to `false`.
|
|
3064
|
+
*/
|
|
3065
|
+
fullPage?: boolean;
|
|
3066
|
+
} & ScreenshotOptions,
|
|
3067
|
+
): Promise<ArrayBuffer>;
|
|
3068
|
+
|
|
3069
|
+
/**
|
|
3070
|
+
* **NOTE** Use locator-based locator.selectOption(values[, options]) instead.
|
|
3071
|
+
*
|
|
3072
|
+
* This select one or more options which match the values from a <select>
|
|
3073
|
+
* element.
|
|
3074
|
+
*
|
|
3075
|
+
* @param selector A selector to search for an element. If there are multiple
|
|
3076
|
+
* elements satisfying the selector, the first will be used.
|
|
3077
|
+
* @param values Options to select. If the select has multiple attribute, all
|
|
3078
|
+
* matching options are selected, otherwise only the first option matching
|
|
3079
|
+
* one of the passed options is selected. Object can be made up of keys with
|
|
3080
|
+
* value, label or index.
|
|
3081
|
+
* @param options
|
|
3082
|
+
*/
|
|
3083
|
+
selectOption(
|
|
3084
|
+
selector: string,
|
|
3085
|
+
values: string | ElementHandle | SelectOptionsObject | string[] | ElementHandle[] | SelectOptionsObject[],
|
|
3086
|
+
options?: {
|
|
3087
|
+
/**
|
|
3088
|
+
* Setting this to `true` will bypass the actionability checks (visible,
|
|
3089
|
+
* stable, enabled). Defaults to `false`.
|
|
3090
|
+
*/
|
|
3091
|
+
force?: boolean;
|
|
3092
|
+
|
|
3093
|
+
/**
|
|
3094
|
+
* If set to `true` and a navigation occurs from performing this action, it
|
|
3095
|
+
* will not wait for it to complete. Defaults to `false`.
|
|
3096
|
+
*/
|
|
3097
|
+
noWaitAfter?: boolean;
|
|
3098
|
+
|
|
3099
|
+
/**
|
|
3100
|
+
* When `true`, the call requires selector to resolve to a single element.
|
|
3101
|
+
* If given selector resolves to more than one element, the call throws
|
|
3102
|
+
* an exception. Defaults to `false`.
|
|
3103
|
+
*/
|
|
3104
|
+
strict?: boolean;
|
|
3105
|
+
|
|
3106
|
+
/**
|
|
3107
|
+
* Maximum time in milliseconds. Defaults to `30` seconds. Default is
|
|
3108
|
+
* overridden by the `setDefaultTimeout` option on `BrowserContext` or
|
|
3109
|
+
* `page` methods.
|
|
3110
|
+
*
|
|
3111
|
+
* Setting the value to `0` will disable the timeout.
|
|
3112
|
+
*/
|
|
3113
|
+
timeout?: number;
|
|
3114
|
+
},
|
|
3115
|
+
): Promise<string[]>;
|
|
3116
|
+
|
|
3117
|
+
/**
|
|
3118
|
+
* Set the supplied html string to the current page.
|
|
3119
|
+
*
|
|
3120
|
+
* @param html HTML markup to assign to the page.
|
|
3121
|
+
* @param options
|
|
3122
|
+
*/
|
|
3123
|
+
setContent(
|
|
3124
|
+
html: string,
|
|
3125
|
+
options?: {
|
|
3126
|
+
/**
|
|
3127
|
+
* Maximum operation time in milliseconds. Defaults to `30` seconds. The
|
|
3128
|
+
* default value can be changed via the
|
|
3129
|
+
* browserContext.setDefaultNavigationTimeout(timeout),
|
|
3130
|
+
* browserContext.setDefaultTimeout(timeout),
|
|
3131
|
+
* page.setDefaultNavigationTimeout(timeout) or
|
|
3132
|
+
* page.setDefaultTimeout(timeout) methods.
|
|
3133
|
+
*
|
|
3134
|
+
* Setting the value to `0` will disable the timeout.
|
|
3135
|
+
*/
|
|
3136
|
+
timeout?: number;
|
|
3137
|
+
|
|
3138
|
+
/**
|
|
3139
|
+
* When to consider operation succeeded, defaults to `load`. Events can be
|
|
3140
|
+
* either:
|
|
3141
|
+
* - `'domcontentloaded'` - consider operation to be finished when the
|
|
3142
|
+
* `DOMContentLoaded` event is fired.
|
|
3143
|
+
* - `'load'` - consider operation to be finished when the `load` event is
|
|
3144
|
+
* fired.
|
|
3145
|
+
* - `'networkidle'` - **DISCOURAGED** consider operation to be finished
|
|
3146
|
+
* when there are no network connections for at least `500` ms. Don't use
|
|
3147
|
+
* this method for testing especially with chatty websites where the event
|
|
3148
|
+
* may never fire, rely on web assertions to assess readiness instead.
|
|
3149
|
+
*/
|
|
3150
|
+
waitUntil?: "load" | "domcontentloaded" | "networkidle";
|
|
3151
|
+
},
|
|
3152
|
+
): Promise<void>;
|
|
3153
|
+
|
|
3154
|
+
/**
|
|
3155
|
+
* This setting will change the navigation timeout for the following methods:
|
|
3156
|
+
* - page.goto(url[, options])
|
|
3157
|
+
* - page.reload([options])
|
|
3158
|
+
* - page.setContent(html[, options])
|
|
3159
|
+
* - page.waitForNavigation([options])
|
|
3160
|
+
*
|
|
3161
|
+
* @param timeout in milliseconds
|
|
3162
|
+
*/
|
|
3163
|
+
setDefaultNavigationTimeout(timeout: number): void;
|
|
3164
|
+
|
|
3165
|
+
/**
|
|
3166
|
+
* This setting will change the timeout for all the methods accepting a
|
|
3167
|
+
* `timeout` option.
|
|
3168
|
+
*
|
|
3169
|
+
* @param timeout in milliseconds
|
|
3170
|
+
*/
|
|
3171
|
+
setDefaultTimeout(timeout: number): void;
|
|
3172
|
+
|
|
3173
|
+
/**
|
|
3174
|
+
* This sets extra HTTP headers which will be sent with subsequent
|
|
3175
|
+
* HTTP requests.
|
|
3176
|
+
*
|
|
3177
|
+
* @param headers An object containing the additional HTTP headers.
|
|
3178
|
+
* All header values must be strings.
|
|
3179
|
+
*/
|
|
3180
|
+
setExtraHTTPHeaders(headers: { [key: string]: string }): Promise<void>;
|
|
3181
|
+
|
|
3182
|
+
/**
|
|
3183
|
+
* Sets the file input element's value to the specified files.
|
|
3184
|
+
*
|
|
3185
|
+
* To work with local files on the file system, use the experimental
|
|
3186
|
+
* fs module to load and read the file contents.
|
|
3187
|
+
*
|
|
3188
|
+
* This method expects a `selector` to point to an
|
|
3189
|
+
* [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
|
|
3190
|
+
* @param selector A selector to search for an element. If there are multiple
|
|
3191
|
+
* elements satisfying the selector, the first will be used.
|
|
3192
|
+
* @param files
|
|
3193
|
+
* @param options
|
|
3194
|
+
*/
|
|
3195
|
+
setInputFiles(selector: string, files: File | File[], options?: {
|
|
3196
|
+
/**
|
|
3197
|
+
* Maximum time in milliseconds. Pass 0 to disable the timeout. Default
|
|
3198
|
+
* is overridden by the setDefaultTimeout option on {@link BrowserContext} or
|
|
3199
|
+
* {@link Page}
|
|
3200
|
+
* @default 30000
|
|
3201
|
+
*/
|
|
3202
|
+
timeout?: number;
|
|
3203
|
+
|
|
3204
|
+
/**
|
|
3205
|
+
* If set to `true` and a navigation occurs from performing this action, it
|
|
3206
|
+
* will not wait for it to complete.
|
|
3207
|
+
* @default false
|
|
3208
|
+
*/
|
|
3209
|
+
noWaitAfter?: boolean;
|
|
3210
|
+
}): Promise<void>;
|
|
3211
|
+
|
|
3212
|
+
/**
|
|
3213
|
+
* This will update the page's width and height.
|
|
3214
|
+
*
|
|
3215
|
+
* @param viewportSize
|
|
3216
|
+
*/
|
|
3217
|
+
setViewportSize(viewportSize: {
|
|
3218
|
+
/**
|
|
3219
|
+
* page width in pixels.
|
|
3220
|
+
*/
|
|
3221
|
+
width: number;
|
|
3222
|
+
|
|
3223
|
+
/**
|
|
3224
|
+
* page height in pixels.
|
|
3225
|
+
*/
|
|
3226
|
+
height: number;
|
|
3227
|
+
}): Promise<void>;
|
|
3228
|
+
|
|
3229
|
+
/**
|
|
3230
|
+
* **NOTE** Use locator-based locator.tap([options]) instead.
|
|
3231
|
+
*
|
|
3232
|
+
* Tap the first element that matches the selector.
|
|
3233
|
+
*
|
|
3234
|
+
* @param selector A selector to search for an element. If there are multiple
|
|
3235
|
+
* elements satisfying the selector, the first will be used.
|
|
3236
|
+
* @param options
|
|
3237
|
+
*/
|
|
3238
|
+
tap(
|
|
3239
|
+
selector: string,
|
|
3240
|
+
options?: {
|
|
3241
|
+
/**
|
|
3242
|
+
* Setting this to `true` will bypass the actionability checks (visible,
|
|
3243
|
+
* stable, enabled). Defaults to `false`.
|
|
3244
|
+
*/
|
|
3245
|
+
force?: boolean;
|
|
3246
|
+
|
|
3247
|
+
/**
|
|
3248
|
+
* `Alt`, `Control`, `Meta` or `Shift` modifiers keys pressed during the
|
|
3249
|
+
* action. If not specified, currently pressed modifiers are used,
|
|
3250
|
+
* otherwise defaults to `null`.
|
|
3251
|
+
*/
|
|
3252
|
+
modifiers?: KeyboardModifier[];
|
|
3253
|
+
|
|
3254
|
+
/**
|
|
3255
|
+
* If set to `true` and a navigation occurs from performing this action, it
|
|
3256
|
+
* will not wait for it to complete. Defaults to `false`.
|
|
3257
|
+
*/
|
|
3258
|
+
noWaitAfter?: boolean;
|
|
3259
|
+
|
|
3260
|
+
/**
|
|
3261
|
+
* A point to use relative to the top left corner of the element. If not
|
|
3262
|
+
* supplied, a visible point of the element is used.
|
|
3263
|
+
*/
|
|
3264
|
+
position?: {
|
|
3265
|
+
x: number;
|
|
3266
|
+
|
|
3267
|
+
y: number;
|
|
3268
|
+
};
|
|
3269
|
+
|
|
3270
|
+
/**
|
|
3271
|
+
* When `true`, the call requires selector to resolve to a single element.
|
|
3272
|
+
* If given selector resolves to more than one element, the call throws
|
|
3273
|
+
* an exception. Defaults to `false`.
|
|
3274
|
+
*/
|
|
3275
|
+
strict?: boolean;
|
|
3276
|
+
|
|
3277
|
+
/**
|
|
3278
|
+
* Maximum time in milliseconds. Defaults to `30` seconds. Default is
|
|
3279
|
+
* overridden by the `setDefaultTimeout` option on `BrowserContext` or
|
|
3280
|
+
* `page` methods.
|
|
3281
|
+
*
|
|
3282
|
+
* Setting the value to `0` will disable the timeout.
|
|
3283
|
+
*/
|
|
3284
|
+
timeout?: number;
|
|
3285
|
+
|
|
3286
|
+
/**
|
|
3287
|
+
* Setting this to `true` will perform the actionability checks without
|
|
3288
|
+
* performing the action. Useful to wait until the element is ready for the
|
|
3289
|
+
* action without performing it. Defaults to `false`.
|
|
3290
|
+
*/
|
|
3291
|
+
trial?: boolean;
|
|
3292
|
+
},
|
|
3293
|
+
): Promise<void>;
|
|
3294
|
+
|
|
3295
|
+
/**
|
|
3296
|
+
* **NOTE** Use locator-based locator.textContent([options]) instead.
|
|
3297
|
+
*
|
|
3298
|
+
* Returns `element.textContent`.
|
|
3299
|
+
*
|
|
3300
|
+
* @param selector A selector to search for an element. If there are multiple
|
|
3301
|
+
* elements satisfying the selector, the first will be used.
|
|
3302
|
+
* @param options
|
|
3303
|
+
*/
|
|
3304
|
+
textContent(
|
|
3305
|
+
selector: string,
|
|
3306
|
+
options?: {
|
|
3307
|
+
/**
|
|
3308
|
+
* When `true`, the call requires selector to resolve to a single element.
|
|
3309
|
+
* If given selector resolves to more than one element, the call throws
|
|
3310
|
+
* an exception. Defaults to `false`.
|
|
3311
|
+
*/
|
|
3312
|
+
strict?: boolean;
|
|
3313
|
+
|
|
3314
|
+
/**
|
|
3315
|
+
* Maximum time in milliseconds. Defaults to `30` seconds. Default is
|
|
3316
|
+
* overridden by the `setDefaultTimeout` option on `BrowserContext` or
|
|
3317
|
+
* `page` methods.
|
|
3318
|
+
*
|
|
3319
|
+
* Setting the value to `0` will disable the timeout.
|
|
3320
|
+
*/
|
|
3321
|
+
timeout?: number;
|
|
3322
|
+
},
|
|
3323
|
+
): Promise<string | null>;
|
|
3324
|
+
|
|
3325
|
+
/**
|
|
3326
|
+
* Throttles the CPU in Chrome/Chromium to slow it down by the specified
|
|
3327
|
+
* `rate` in {@link CPUProfile}. {@link CPUProfile} is a mandatory
|
|
3328
|
+
* input argument. The default `rate` is `1`.
|
|
3329
|
+
*
|
|
3330
|
+
* **Usage**
|
|
3331
|
+
*
|
|
3332
|
+
* ```js
|
|
3333
|
+
* page.throttleCPU({ rate: 4 });
|
|
3334
|
+
* ```
|
|
3335
|
+
*/
|
|
3336
|
+
throttleCPU(profile: CPUProfile): Promise<void>;
|
|
3337
|
+
|
|
3338
|
+
/**
|
|
3339
|
+
* Throttles the network in Chrome/Chromium to slow it down by the specified
|
|
3340
|
+
* fields in {@link NetworkProfile}. {@link NetworkProfile} is a mandatory
|
|
3341
|
+
* input argument.
|
|
3342
|
+
*
|
|
3343
|
+
* **Usage**
|
|
3344
|
+
*
|
|
3345
|
+
* ```js
|
|
3346
|
+
* page.throttleNetwork({
|
|
3347
|
+
* latency: 750,
|
|
3348
|
+
* download: 250,
|
|
3349
|
+
* upload: 250,
|
|
3350
|
+
* });
|
|
3351
|
+
* ```
|
|
3352
|
+
*
|
|
3353
|
+
* To work with the most commonly tested network profiles, import `networkProfiles`
|
|
3354
|
+
* from the browser module. There are three profiles available:
|
|
3355
|
+
* - `'No Throttling'` (default)
|
|
3356
|
+
* - `'Fast 3G'`
|
|
3357
|
+
* - `'Slow 3G'`
|
|
3358
|
+
*
|
|
3359
|
+
* **Usage**
|
|
3360
|
+
*
|
|
3361
|
+
* ```js
|
|
3362
|
+
* import { browser, networkProfiles } from 'k6/experimental/browser';
|
|
3363
|
+
* ... // redacted
|
|
3364
|
+
* const context = browser.newContext();
|
|
3365
|
+
* const page = context.newPage();
|
|
3366
|
+
*
|
|
3367
|
+
* try {
|
|
3368
|
+
* page.throttleNetwork(networkProfiles['Slow 3G']);
|
|
3369
|
+
* ... // redacted
|
|
3370
|
+
* ```
|
|
3371
|
+
*/
|
|
3372
|
+
throttleNetwork(profile: NetworkProfile): Promise<void>;
|
|
3373
|
+
|
|
3374
|
+
/**
|
|
3375
|
+
* Returns the page's title.
|
|
3376
|
+
*/
|
|
3377
|
+
title(): Promise<string>;
|
|
3378
|
+
|
|
3379
|
+
/**
|
|
3380
|
+
* Returns the touchscreen instance to interact with a virtual touchscreen on
|
|
3381
|
+
* the page.
|
|
3382
|
+
*/
|
|
3383
|
+
touchscreen: Touchscreen;
|
|
3384
|
+
|
|
3385
|
+
/**
|
|
3386
|
+
* **NOTE** Use locator-based locator.type(text[, options]) instead.
|
|
3387
|
+
*
|
|
3388
|
+
* Type the `text` in the first element found that matches the selector.
|
|
3389
|
+
*
|
|
3390
|
+
* @param selector A selector to search for an element. If there are multiple
|
|
3391
|
+
* elements satisfying the selector, the first will be used.
|
|
3392
|
+
* @param text The text to type into the element.
|
|
3393
|
+
* @param options
|
|
3394
|
+
*/
|
|
3395
|
+
type(
|
|
3396
|
+
selector: string,
|
|
3397
|
+
text: string,
|
|
3398
|
+
options?: {
|
|
3399
|
+
/**
|
|
3400
|
+
* Milliseconds to wait between `mousedown` and `mouseup`. Defaults to `0`.
|
|
3401
|
+
*/
|
|
3402
|
+
delay?: number;
|
|
3403
|
+
|
|
3404
|
+
/**
|
|
3405
|
+
* If set to `true` and a navigation occurs from performing this action, it
|
|
3406
|
+
* will not wait for it to complete. Defaults to `false`.
|
|
3407
|
+
*/
|
|
3408
|
+
noWaitAfter?: boolean;
|
|
3409
|
+
|
|
3410
|
+
/**
|
|
3411
|
+
* When `true`, the call requires selector to resolve to a single element.
|
|
3412
|
+
* If given selector resolves to more than one element, the call throws
|
|
3413
|
+
* an exception. Defaults to `false`.
|
|
3414
|
+
*/
|
|
3415
|
+
strict?: boolean;
|
|
3416
|
+
|
|
3417
|
+
/**
|
|
3418
|
+
* Maximum time in milliseconds. Defaults to `30` seconds. Default is
|
|
3419
|
+
* overridden by the `setDefaultTimeout` option on `BrowserContext` or
|
|
3420
|
+
* `page` methods.
|
|
3421
|
+
*
|
|
3422
|
+
* Setting the value to `0` will disable the timeout.
|
|
3423
|
+
*/
|
|
3424
|
+
timeout?: number;
|
|
3425
|
+
},
|
|
3426
|
+
): Promise<void>;
|
|
3427
|
+
|
|
3428
|
+
/**
|
|
3429
|
+
* **NOTE** Use locator-based `locator.uncheck([options])` instead.
|
|
3430
|
+
*
|
|
3431
|
+
* This method is used to unselect an input checkbox.
|
|
3432
|
+
*
|
|
3433
|
+
* @param selector A selector to search for an element. If there are multiple
|
|
3434
|
+
* elements satisfying the selector, the first will be used.
|
|
3435
|
+
* @param options
|
|
3436
|
+
*/
|
|
3437
|
+
uncheck(
|
|
3438
|
+
selector: string,
|
|
3439
|
+
options?: {
|
|
3440
|
+
/**
|
|
3441
|
+
* Setting this to `true` will bypass the actionability checks (visible,
|
|
3442
|
+
* stable, enabled). Defaults to `false`.
|
|
3443
|
+
*/
|
|
3444
|
+
force?: boolean;
|
|
3445
|
+
|
|
3446
|
+
/**
|
|
3447
|
+
* If set to `true` and a navigation occurs from performing this action, it
|
|
3448
|
+
* will not wait for it to complete. Defaults to `false`.
|
|
3449
|
+
*/
|
|
3450
|
+
noWaitAfter?: boolean;
|
|
3451
|
+
|
|
3452
|
+
/**
|
|
3453
|
+
* A point to use relative to the top left corner of the element. If not
|
|
3454
|
+
* supplied, a visible point of the element is used.
|
|
3455
|
+
*/
|
|
3456
|
+
position?: {
|
|
3457
|
+
x: number;
|
|
3458
|
+
|
|
3459
|
+
y: number;
|
|
3460
|
+
};
|
|
3461
|
+
|
|
3462
|
+
/**
|
|
3463
|
+
* When `true`, the call requires selector to resolve to a single element.
|
|
3464
|
+
* If given selector resolves to more than one element, the call throws
|
|
3465
|
+
* an exception. Defaults to `false`.
|
|
3466
|
+
*/
|
|
3467
|
+
strict?: boolean;
|
|
3468
|
+
|
|
3469
|
+
/**
|
|
3470
|
+
* Maximum time in milliseconds. Defaults to `30` seconds. Default is
|
|
3471
|
+
* overridden by the `setDefaultTimeout` option on `BrowserContext` or
|
|
3472
|
+
* `page` methods.
|
|
3473
|
+
*
|
|
3474
|
+
* Setting the value to `0` will disable the timeout.
|
|
3475
|
+
*/
|
|
3476
|
+
timeout?: number;
|
|
3477
|
+
|
|
3478
|
+
/**
|
|
3479
|
+
* Setting this to `true` will perform the actionability checks without
|
|
3480
|
+
* performing the action. Useful to wait until the element is ready for the
|
|
3481
|
+
* action without performing it. Defaults to `false`.
|
|
3482
|
+
*/
|
|
3483
|
+
trial?: boolean;
|
|
3484
|
+
},
|
|
3485
|
+
): Promise<void>;
|
|
3486
|
+
|
|
3487
|
+
/**
|
|
3488
|
+
* Returns the page's URL.
|
|
3489
|
+
*/
|
|
3490
|
+
url(): string;
|
|
3491
|
+
|
|
3492
|
+
/**
|
|
3493
|
+
* Returns the page's size (width and height).
|
|
3494
|
+
*/
|
|
3495
|
+
viewportSize(): {
|
|
3496
|
+
/**
|
|
3497
|
+
* page width in pixels.
|
|
3498
|
+
*/
|
|
3499
|
+
width: number;
|
|
3500
|
+
|
|
3501
|
+
/**
|
|
3502
|
+
* page height in pixels.
|
|
3503
|
+
*/
|
|
3504
|
+
height: number;
|
|
3505
|
+
};
|
|
3506
|
+
|
|
3507
|
+
/**
|
|
3508
|
+
* Returns when the `pageFunction` returns a truthy value.
|
|
3509
|
+
*
|
|
3510
|
+
* @param pageFunction Function to be evaluated in the page context.
|
|
3511
|
+
* @param arg Optional argument to pass to `pageFunction`.
|
|
3512
|
+
* @param options
|
|
3513
|
+
*/
|
|
3514
|
+
waitForFunction<R, Arg>(
|
|
3515
|
+
pageFunction: PageFunction<Arg, R>,
|
|
3516
|
+
options?: {
|
|
3517
|
+
/**
|
|
3518
|
+
* If `polling` is `'raf'`, then `pageFunction` is constantly executed in
|
|
3519
|
+
* `requestAnimationFrame` callback. If `polling` is a number, then it is
|
|
3520
|
+
* treated as an interval in milliseconds at which the function would be
|
|
3521
|
+
* executed. Defaults to `raf`.
|
|
3522
|
+
*/
|
|
3523
|
+
polling?: number | "raf";
|
|
3524
|
+
|
|
3525
|
+
/**
|
|
3526
|
+
* Maximum time in milliseconds. Defaults to `30` seconds. Default is
|
|
3527
|
+
* overridden by the `setDefaultTimeout` option on `BrowserContext` or
|
|
3528
|
+
* `page` methods.
|
|
3529
|
+
*
|
|
3530
|
+
* Setting the value to `0` will disable the timeout.
|
|
3531
|
+
*/
|
|
3532
|
+
timeout?: number;
|
|
3533
|
+
},
|
|
3534
|
+
arg?: Arg,
|
|
3535
|
+
): Promise<JSHandle<R>>;
|
|
3536
|
+
|
|
3537
|
+
/**
|
|
3538
|
+
* This waits for the given load state to be reached. It will immediately
|
|
3539
|
+
* unblock if that lifecycle event has already been received.
|
|
3540
|
+
*
|
|
3541
|
+
* @param state Optional load state to wait for, defaults to `load`:
|
|
3542
|
+
* - `'domcontentloaded'` - consider operation to be finished when the
|
|
3543
|
+
* `DOMContentLoaded` event is fired.
|
|
3544
|
+
* - `'load'` - consider operation to be finished when the `load` event is
|
|
3545
|
+
* fired.
|
|
3546
|
+
* - `'networkidle'` - **DISCOURAGED** consider operation to be finished
|
|
3547
|
+
* when there are no network connections for at least `500` ms. Don't use
|
|
3548
|
+
* this method for testing especially with chatty websites where the event
|
|
3549
|
+
* may never fire, rely on web assertions to assess readiness instead.
|
|
3550
|
+
* @param options
|
|
3551
|
+
*/
|
|
3552
|
+
waitForLoadState(
|
|
3553
|
+
state?: "load" | "domcontentloaded" | "networkidle",
|
|
3554
|
+
options?: {
|
|
3555
|
+
/**
|
|
3556
|
+
* Maximum operation time in milliseconds. Defaults to `30` seconds. The
|
|
3557
|
+
* default value can be changed via the
|
|
3558
|
+
* browserContext.setDefaultNavigationTimeout(timeout),
|
|
3559
|
+
* browserContext.setDefaultTimeout(timeout),
|
|
3560
|
+
* page.setDefaultNavigationTimeout(timeout) or
|
|
3561
|
+
* page.setDefaultTimeout(timeout) methods.
|
|
3562
|
+
*
|
|
3563
|
+
* Setting the value to `0` will disable the timeout.
|
|
3564
|
+
*/
|
|
3565
|
+
timeout?: number;
|
|
3566
|
+
},
|
|
3567
|
+
): Promise<void>;
|
|
3568
|
+
|
|
3569
|
+
/**
|
|
3570
|
+
* Waits for the given navigation lifecycle event to occur and returns the main
|
|
3571
|
+
* resource response.
|
|
3572
|
+
*
|
|
3573
|
+
* @param options
|
|
3574
|
+
*/
|
|
3575
|
+
waitForNavigation(options?: {
|
|
3576
|
+
/**
|
|
3577
|
+
* Maximum operation time in milliseconds. Defaults to `30` seconds. The
|
|
3578
|
+
* default value can be changed via the
|
|
3579
|
+
* browserContext.setDefaultNavigationTimeout(timeout),
|
|
3580
|
+
* browserContext.setDefaultTimeout(timeout),
|
|
3581
|
+
* page.setDefaultNavigationTimeout(timeout) or
|
|
3582
|
+
* page.setDefaultTimeout(timeout) methods.
|
|
3583
|
+
*
|
|
3584
|
+
* Setting the value to `0` will disable the timeout.
|
|
3585
|
+
*/
|
|
3586
|
+
timeout?: number;
|
|
3587
|
+
|
|
3588
|
+
/**
|
|
3589
|
+
* When to consider operation succeeded, defaults to `load`. Events can be
|
|
3590
|
+
* either:
|
|
3591
|
+
* - `'domcontentloaded'` - consider operation to be finished when the
|
|
3592
|
+
* `DOMContentLoaded` event is fired.
|
|
3593
|
+
* - `'load'` - consider operation to be finished when the `load` event is
|
|
3594
|
+
* fired.
|
|
3595
|
+
* - `'networkidle'` - **DISCOURAGED** consider operation to be finished
|
|
3596
|
+
* when there are no network connections for at least `500` ms. Don't use
|
|
3597
|
+
* this method for testing especially with chatty websites where the event
|
|
3598
|
+
* may never fire, rely on web assertions to assess readiness instead.
|
|
3599
|
+
*/
|
|
3600
|
+
waitUntil?: "load" | "domcontentloaded" | "networkidle";
|
|
3601
|
+
}): Promise<Response | null>;
|
|
3602
|
+
|
|
3603
|
+
/**
|
|
3604
|
+
* **NOTE** Use web assertions that assert visibility or a locator-based
|
|
3605
|
+
* locator.waitFor([options]) instead.
|
|
3606
|
+
*
|
|
3607
|
+
* Returns when element specified by selector satisfies `state` option.
|
|
3608
|
+
*
|
|
3609
|
+
* @param selector A selector to query for.
|
|
3610
|
+
* @param options
|
|
3611
|
+
*/
|
|
3612
|
+
waitForSelector(
|
|
3613
|
+
selector: string,
|
|
3614
|
+
options?: {
|
|
3615
|
+
/**
|
|
3616
|
+
* Defaults to `'visible'`. Can be either:
|
|
3617
|
+
* - `'attached'` - wait for element to be present in DOM.
|
|
3618
|
+
* - `'detached'` - wait for element to not be present in DOM.
|
|
3619
|
+
* - `'visible'` - wait for element to have non-empty bounding box and no
|
|
3620
|
+
* `visibility:hidden`.
|
|
3621
|
+
* - `'hidden'` - wait for element to be either detached from DOM, or have
|
|
3622
|
+
* an empty bounding box or `visibility:hidden`.
|
|
3623
|
+
*/
|
|
3624
|
+
state?: "attached" | "detached" | "visible" | "hidden";
|
|
3625
|
+
|
|
3626
|
+
/**
|
|
3627
|
+
* When `true`, the call requires selector to resolve to a single element.
|
|
3628
|
+
* If given selector resolves to more than one element, the call throws
|
|
3629
|
+
* an exception. Defaults to `false`.
|
|
3630
|
+
*/
|
|
3631
|
+
strict?: boolean;
|
|
3632
|
+
|
|
3633
|
+
/**
|
|
3634
|
+
* Maximum time in milliseconds. Defaults to `30` seconds. Default is
|
|
3635
|
+
* overridden by the `setDefaultTimeout` option on `BrowserContext` or
|
|
3636
|
+
* `page` methods.
|
|
3637
|
+
*
|
|
3638
|
+
* Setting the value to `0` will disable the timeout.
|
|
3639
|
+
*/
|
|
3640
|
+
timeout?: number;
|
|
3641
|
+
},
|
|
3642
|
+
): Promise<ElementHandle>;
|
|
3643
|
+
|
|
3644
|
+
/**
|
|
3645
|
+
* **NOTE** Never wait for timeout in production, use this only for debugging.
|
|
3646
|
+
* Tests that wait for time are inherently flaky. Use `Locator` actions and
|
|
3647
|
+
* web assertions that wait automatically.
|
|
3648
|
+
*
|
|
3649
|
+
* Waits for the given `timeout` in milliseconds.
|
|
3650
|
+
*
|
|
3651
|
+
* @param timeout A timeout to wait for
|
|
3652
|
+
*/
|
|
3653
|
+
waitForTimeout(timeout: number): Promise<void>;
|
|
3654
|
+
|
|
3655
|
+
/**
|
|
3656
|
+
* This method returns all of the dedicated WebWorkers associated with the page.
|
|
3657
|
+
*/
|
|
3658
|
+
workers(): Worker[];
|
|
3659
|
+
|
|
3660
|
+
/**
|
|
3661
|
+
* **NOTE** Use locator-based page.locator(selector[, options]) instead.
|
|
3662
|
+
*
|
|
3663
|
+
* The method finds an element matching the specified selector within the page.
|
|
3664
|
+
* If no elements match the selector, the return value resolves to `null`.
|
|
3665
|
+
* To wait for an element on the page, use locator.waitFor([options]).
|
|
3666
|
+
* @param selector A selector to query for.
|
|
3667
|
+
*/
|
|
3668
|
+
$(selector: string): Promise<ElementHandle | null>;
|
|
3669
|
+
|
|
3670
|
+
/**
|
|
3671
|
+
* **NOTE** Use locator-based page.locator(selector[, options]) instead.
|
|
3672
|
+
*
|
|
3673
|
+
* The method finds all elements matching the specified selector within the
|
|
3674
|
+
* page. If no elements match the selector, the return value resolves to `[]`.
|
|
3675
|
+
* @param selector A selector to query for.
|
|
3676
|
+
*/
|
|
3677
|
+
$$(selector: string): Promise<ElementHandle[]>;
|
|
3678
|
+
}
|
|
3679
|
+
|
|
3680
|
+
/**
|
|
3681
|
+
* Request represents requests which are sent by a page.
|
|
3682
|
+
*/
|
|
3683
|
+
export interface Request {
|
|
3684
|
+
/**
|
|
3685
|
+
* An object with HTTP headers associated with the request. All header names are
|
|
3686
|
+
* lower-case.
|
|
3687
|
+
* @returns The headers object.
|
|
3688
|
+
*/
|
|
3689
|
+
allHeaders(): Promise<Record<string, string>>;
|
|
3690
|
+
|
|
3691
|
+
/**
|
|
3692
|
+
* @returns the Frame that initiated this request
|
|
3693
|
+
*/
|
|
3694
|
+
frame(): Frame;
|
|
3695
|
+
|
|
3696
|
+
/**
|
|
3697
|
+
* An object with HTTP headers associated with the request. All header names are
|
|
3698
|
+
* lower-case.
|
|
3699
|
+
* @returns An object with HTTP headers associated with the request.
|
|
3700
|
+
*/
|
|
3701
|
+
headers(): Record<string, string>;
|
|
3702
|
+
|
|
3703
|
+
/**
|
|
3704
|
+
* An array with all the request HTTP headers. Unlike `Request.allHeaders()`,
|
|
3705
|
+
* header names are not lower-cased. Headers with multiple entries, such as
|
|
3706
|
+
* `Set-Cookie`, appear in the array multiple times.
|
|
3707
|
+
* @returns An array of all the request HTTP headers.
|
|
3708
|
+
*/
|
|
3709
|
+
headersArray(): Promise<Array<{ name: string; value: string }>>;
|
|
3710
|
+
|
|
3711
|
+
/**
|
|
3712
|
+
* Retuns the value of the header matching the name. The name is case insensitive.
|
|
3713
|
+
* @param name Header name to retrieve value for.
|
|
3714
|
+
* @returns The value of the header matching the name.
|
|
3715
|
+
*/
|
|
3716
|
+
headerValue(name: string): Promise<string | null>;
|
|
3717
|
+
|
|
3718
|
+
/**
|
|
3719
|
+
* @returns a boolean stating whether the request is for a navigation
|
|
3720
|
+
*/
|
|
3721
|
+
isNavigationRequest(): boolean;
|
|
3722
|
+
|
|
3723
|
+
/**
|
|
3724
|
+
* Request's method (GET, POST, etc.)
|
|
3725
|
+
* @returns request's method name
|
|
3726
|
+
*/
|
|
3727
|
+
method(): string;
|
|
3728
|
+
|
|
3729
|
+
/**
|
|
3730
|
+
* Contains the request's post body, if any.
|
|
3731
|
+
* @returns request's post body
|
|
3732
|
+
*/
|
|
3733
|
+
postData(): string | null;
|
|
3734
|
+
|
|
3735
|
+
/**
|
|
3736
|
+
* Request's post body in a binary form, if any.
|
|
3737
|
+
* @returns an ArrayBuffer with request's post data
|
|
3738
|
+
*/
|
|
3739
|
+
postDataBuffer(): ArrayBuffer | null;
|
|
3740
|
+
|
|
3741
|
+
/**
|
|
3742
|
+
* Contains the request's resource type as it was perceived by the rendering engine.
|
|
3743
|
+
* ResourceType will be one of the following: `document`, `stylesheet`, `image`,
|
|
3744
|
+
* `media`, `font`, `script`, `texttrack`, `xhr`, `fetch`, `eventsource`,
|
|
3745
|
+
* `websocket`, `manifest`, `other`.
|
|
3746
|
+
* @returns resource type name
|
|
3747
|
+
*/
|
|
3748
|
+
resourceType(): ResourceType;
|
|
3749
|
+
|
|
3750
|
+
/**
|
|
3751
|
+
* Returns the matching `Response` object, or `null` if the response was not received
|
|
3752
|
+
* due to error.
|
|
3753
|
+
* @returns The `Response` object, or `null` if the response was not received due to error.
|
|
3754
|
+
*/
|
|
3755
|
+
response(): Promise<Response | null>;
|
|
3756
|
+
|
|
3757
|
+
/**
|
|
3758
|
+
* Returns resource size information for given request.
|
|
3759
|
+
* @returns Resource size information for given request.
|
|
3760
|
+
*/
|
|
3761
|
+
size(): Promise<{ body: number; headers: number }>;
|
|
3762
|
+
|
|
3763
|
+
/**
|
|
3764
|
+
* Returns resource timing information for given request. Most of the timing values
|
|
3765
|
+
* become available upon the response, `responseEnd` becomes available when request
|
|
3766
|
+
* finishes.
|
|
3767
|
+
* @returns Resource timing information for given request.
|
|
3768
|
+
*/
|
|
3769
|
+
timing(): ResourceTiming;
|
|
3770
|
+
|
|
3771
|
+
/**
|
|
3772
|
+
* URL of the request.
|
|
3773
|
+
* @returns request URL
|
|
3774
|
+
*/
|
|
3775
|
+
url(): string;
|
|
3776
|
+
}
|
|
3777
|
+
|
|
3778
|
+
/**
|
|
3779
|
+
* Response represents responses which are received by page.
|
|
3780
|
+
*/
|
|
3781
|
+
export interface Response {
|
|
3782
|
+
/**
|
|
3783
|
+
* An object with HTTP headers associated with the response. All header names are
|
|
3784
|
+
* lower-case.
|
|
3785
|
+
* @returns The headers object.
|
|
3786
|
+
*/
|
|
3787
|
+
allHeaders(): Promise<Record<string, string>>;
|
|
3788
|
+
|
|
3789
|
+
/**
|
|
3790
|
+
* Returns the response body.
|
|
3791
|
+
* @returns A buffer with response body.
|
|
3792
|
+
*/
|
|
3793
|
+
body(): Promise<ArrayBuffer>;
|
|
3794
|
+
|
|
3795
|
+
/**
|
|
3796
|
+
* @returns the Frame that initiated this response
|
|
3797
|
+
*/
|
|
3798
|
+
frame(): Frame;
|
|
3799
|
+
|
|
3800
|
+
/**
|
|
3801
|
+
* An object with HTTP headers associated with the response. All header names are
|
|
3802
|
+
* lower-case.
|
|
3803
|
+
* @returns The headers object.
|
|
3804
|
+
*/
|
|
3805
|
+
headers(): Record<string, string>;
|
|
3806
|
+
|
|
3807
|
+
/**
|
|
3808
|
+
* An array with all the request HTTP response headers. Unlike `Response.headers()`, header
|
|
3809
|
+
* names are not lower-cased. Headers with multiple entries, such as `Set-Cookie`,
|
|
3810
|
+
* appear in the array multiple times.
|
|
3811
|
+
* @returns An array of all the request HTTP headers.
|
|
3812
|
+
*/
|
|
3813
|
+
headersArray(): Promise<Array<{ name: string; value: string }>>;
|
|
3814
|
+
|
|
3815
|
+
/**
|
|
3816
|
+
* Returns the value of the header matching the name. The name is case insensitive.
|
|
3817
|
+
* If multiple headers have the same name (except `Set-Cookie`), they are returned
|
|
3818
|
+
* as a list separated by ``,``. For `Set-Cookie`, the `\n` separator is used. If
|
|
3819
|
+
* no headers are found, `null` is returned.
|
|
3820
|
+
* @param name Header name to retrieve value for.
|
|
3821
|
+
* @returns The header value for the given name.
|
|
3822
|
+
*/
|
|
3823
|
+
headerValue(name: string): Promise<string | null>;
|
|
3824
|
+
|
|
3825
|
+
/**
|
|
3826
|
+
* Returns all values of the headers matching the name, for example `set-cookie`.
|
|
3827
|
+
* The name is case insensitive.
|
|
3828
|
+
* @param name Header name to retrieve values for.
|
|
3829
|
+
* @returns An array of header values for the given name.
|
|
3830
|
+
*/
|
|
3831
|
+
headerValues(name: string): Promise<string[]>;
|
|
3832
|
+
|
|
3833
|
+
/**
|
|
3834
|
+
* Returns the JSON representation of response body. Throws if response body is not
|
|
3835
|
+
* parsable via `JSON.parse`.
|
|
3836
|
+
* @returns JSON representation of response body.
|
|
3837
|
+
*/
|
|
3838
|
+
json(): Promise<any>;
|
|
3839
|
+
|
|
3840
|
+
/**
|
|
3841
|
+
* Contains a boolean stating whether the response was successful (status in the
|
|
3842
|
+
* range 200-299) or not.
|
|
3843
|
+
* @returns a boolean stating whether the response was successful
|
|
3844
|
+
*/
|
|
3845
|
+
ok(): boolean;
|
|
3846
|
+
|
|
3847
|
+
/**
|
|
3848
|
+
* The request that was used to produce the response.
|
|
3849
|
+
* @returns the matching `Request` object
|
|
3850
|
+
*/
|
|
3851
|
+
request(): Request;
|
|
3852
|
+
|
|
3853
|
+
/**
|
|
3854
|
+
* Security details associated with this response.
|
|
3855
|
+
* @returns A matching `SecurityDetailsObject`
|
|
3856
|
+
*/
|
|
3857
|
+
securityDetails(): Promise<SecurityDetailsObject | null>;
|
|
3858
|
+
|
|
3859
|
+
/**
|
|
3860
|
+
* Returns the IP address and port of the server for this response.
|
|
3861
|
+
* @returns The IP address and port of the server
|
|
3862
|
+
*/
|
|
3863
|
+
serverAddr(): Promise<{ ipAddress: string; port: number } | null>;
|
|
3864
|
+
|
|
3865
|
+
/**
|
|
3866
|
+
* Contains the status code of the response (e.g., 200 for a success).
|
|
3867
|
+
* @returns the status code of the response
|
|
3868
|
+
*/
|
|
3869
|
+
status(): number;
|
|
3870
|
+
|
|
3871
|
+
/**
|
|
3872
|
+
* Contains the status text of the response (e.g. usually an "OK" for a success).
|
|
3873
|
+
* @returns the status text of the response
|
|
3874
|
+
*/
|
|
3875
|
+
statusText(): string;
|
|
3876
|
+
|
|
3877
|
+
/**
|
|
3878
|
+
* The size of the response body and the headers.
|
|
3879
|
+
* @returns The size of the response body and the headers.
|
|
3880
|
+
*/
|
|
3881
|
+
size(): Promise<{ body: number; headers: number }>;
|
|
3882
|
+
|
|
3883
|
+
/**
|
|
3884
|
+
* Contains the URL of the response.
|
|
3885
|
+
* @returns the URL of the response
|
|
3886
|
+
*/
|
|
3887
|
+
url(): string;
|
|
3888
|
+
}
|
|
3889
|
+
|
|
3890
|
+
/**
|
|
3891
|
+
* Touchscreen provides an api for interacting with a virtual touchscreen. It
|
|
3892
|
+
* operates in main-frame CSS pixels relative to the top-left corner of the
|
|
3893
|
+
* viewport.
|
|
3894
|
+
*/
|
|
3895
|
+
export interface Touchscreen {
|
|
3896
|
+
/**
|
|
3897
|
+
* Taps on the specified position (`x`,`y`), which internally dispatches a `touchstart` and `touchend` event.
|
|
3898
|
+
* @param x The x position.
|
|
3899
|
+
* @param y The y position.
|
|
3900
|
+
*/
|
|
3901
|
+
tap(x: number, y: number): Promise<void>;
|
|
3902
|
+
}
|
|
3903
|
+
|
|
3904
|
+
/**
|
|
3905
|
+
* The Worker represents a [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API).
|
|
3906
|
+
*/
|
|
3907
|
+
export interface Worker {
|
|
3908
|
+
/**
|
|
3909
|
+
* Get the URL of the web worker.
|
|
3910
|
+
* @return The URL of the web worker.
|
|
3911
|
+
*/
|
|
3912
|
+
url(): string;
|
|
3913
|
+
}
|