@types/k6 0.45.0 → 0.45.2

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