UNPKG

280 kBTypeScriptView Raw
1/// <reference types="node" />
2
3import type { ChildProcess } from 'child_process';
4import type { ParseSelector } from 'typed-query-selector/parser.js';
5import { PassThrough } from 'stream';
6import { Protocol } from 'devtools-protocol';
7import type { ProtocolMapping } from 'devtools-protocol/types/protocol-mapping.js';
8import { Session } from 'chromium-bidi/lib/cjs/protocol/protocol.js';
9
10/**
11 * The Accessibility class provides methods for inspecting the browser's
12 * accessibility tree. The accessibility tree is used by assistive technology
13 * such as {@link https://en.wikipedia.org/wiki/Screen_reader | screen readers} or
14 * {@link https://en.wikipedia.org/wiki/Switch_access | switches}.
15 *
16 * @remarks
17 *
18 * Accessibility is a very platform-specific thing. On different platforms,
19 * there are different screen readers that might have wildly different output.
20 *
21 * Blink - Chrome's rendering engine - has a concept of "accessibility tree",
22 * which is then translated into different platform-specific APIs. Accessibility
23 * namespace gives users access to the Blink Accessibility Tree.
24 *
25 * Most of the accessibility tree gets filtered out when converting from Blink
26 * AX Tree to Platform-specific AX-Tree or by assistive technologies themselves.
27 * By default, Puppeteer tries to approximate this filtering, exposing only
28 * the "interesting" nodes of the tree.
29 *
30 * @public
31 */
32export declare class Accessibility {
33 #private;
34 /* Excluded from this release type: __constructor */
35 /**
36 * Captures the current state of the accessibility tree.
37 * The returned object represents the root accessible node of the page.
38 *
39 * @remarks
40 *
41 * **NOTE** The Chrome accessibility tree contains nodes that go unused on
42 * most platforms and by most screen readers. Puppeteer will discard them as
43 * well for an easier to process tree, unless `interestingOnly` is set to
44 * `false`.
45 *
46 * @example
47 * An example of dumping the entire accessibility tree:
48 *
49 * ```ts
50 * const snapshot = await page.accessibility.snapshot();
51 * console.log(snapshot);
52 * ```
53 *
54 * @example
55 * An example of logging the focused node's name:
56 *
57 * ```ts
58 * const snapshot = await page.accessibility.snapshot();
59 * const node = findFocusedNode(snapshot);
60 * console.log(node && node.name);
61 *
62 * function findFocusedNode(node) {
63 * if (node.focused) return node;
64 * for (const child of node.children || []) {
65 * const foundNode = findFocusedNode(child);
66 * return foundNode;
67 * }
68 * return null;
69 * }
70 * ```
71 *
72 * @returns An AXNode object representing the snapshot.
73 */
74 snapshot(options?: SnapshotOptions): Promise<SerializedAXNode | null>;
75 private serializeTree;
76 private collectInterestingNodes;
77}
78
79/* Excluded from this release type: Action */
80
81/**
82 * @public
83 */
84export declare interface ActionOptions {
85 /**
86 * A signal to abort the locator action.
87 */
88 signal?: AbortSignal;
89}
90
91/**
92 * @public
93 */
94export declare type ActionResult = 'continue' | 'abort' | 'respond';
95
96/* Excluded from this release type: addPageBinding */
97
98/* Excluded from this release type: ARIAQueryHandler */
99
100/* Excluded from this release type: assert */
101
102/* Excluded from this release type: AsyncDisposableStack */
103
104/* Excluded from this release type: asyncDisposeSymbol */
105
106/* Excluded from this release type: AsyncIterableUtil */
107
108/**
109 * @public
110 */
111export declare interface AutofillData {
112 creditCard: {
113 number: string;
114 name: string;
115 expiryMonth: string;
116 expiryYear: string;
117 cvc: string;
118 };
119}
120
121/**
122 * @public
123 */
124export declare type Awaitable<T> = T | PromiseLike<T>;
125
126/**
127 * @public
128 */
129export declare type AwaitableIterable<T> = Iterable<T> | AsyncIterable<T>;
130
131/* Excluded from this release type: AwaitableIterator */
132
133/**
134 * @public
135 */
136export declare type AwaitablePredicate<T> = (value: T) => Awaitable<boolean>;
137
138/**
139 * @public
140 */
141export declare type AwaitedLocator<T> = T extends Locator<infer S> ? S : never;
142
143/* Excluded from this release type: Binding */
144
145/* Excluded from this release type: BindingPayload */
146
147/**
148 * @public
149 */
150export declare interface BoundingBox extends Point {
151 /**
152 * the width of the element in pixels.
153 */
154 width: number;
155 /**
156 * the height of the element in pixels.
157 */
158 height: number;
159}
160
161/**
162 * @public
163 */
164export declare interface BoxModel {
165 content: Quad;
166 padding: Quad;
167 border: Quad;
168 margin: Quad;
169 width: number;
170 height: number;
171}
172
173/**
174 * {@link Browser} represents a browser instance that is either:
175 *
176 * - connected to via {@link Puppeteer.connect} or
177 * - launched by {@link PuppeteerNode.launch}.
178 *
179 * {@link Browser} {@link EventEmitter.emit | emits} various events which are
180 * documented in the {@link BrowserEvent} enum.
181 *
182 * @example Using a {@link Browser} to create a {@link Page}:
183 *
184 * ```ts
185 * import puppeteer from 'puppeteer';
186 *
187 * const browser = await puppeteer.launch();
188 * const page = await browser.newPage();
189 * await page.goto('https://example.com');
190 * await browser.close();
191 * ```
192 *
193 * @example Disconnecting from and reconnecting to a {@link Browser}:
194 *
195 * ```ts
196 * import puppeteer from 'puppeteer';
197 *
198 * const browser = await puppeteer.launch();
199 * // Store the endpoint to be able to reconnect to the browser.
200 * const browserWSEndpoint = browser.wsEndpoint();
201 * // Disconnect puppeteer from the browser.
202 * await browser.disconnect();
203 *
204 * // Use the endpoint to reestablish a connection
205 * const browser2 = await puppeteer.connect({browserWSEndpoint});
206 * // Close the browser.
207 * await browser2.close();
208 * ```
209 *
210 * @public
211 */
212export declare abstract class Browser extends EventEmitter<BrowserEvents> {
213 /* Excluded from this release type: __constructor */
214 /**
215 * Gets the associated
216 * {@link https://nodejs.org/api/child_process.html#class-childprocess | ChildProcess}.
217 *
218 * @returns `null` if this instance was connected to via
219 * {@link Puppeteer.connect}.
220 */
221 abstract process(): ChildProcess | null;
222 /**
223 * Creates a new {@link BrowserContext | browser context}.
224 *
225 * This won't share cookies/cache with other {@link BrowserContext | browser contexts}.
226 *
227 * @example
228 *
229 * ```ts
230 * import puppeteer from 'puppeteer';
231 *
232 * const browser = await puppeteer.launch();
233 * // Create a new browser context.
234 * const context = await browser.createBrowserContext();
235 * // Create a new page in a pristine context.
236 * const page = await context.newPage();
237 * // Do stuff
238 * await page.goto('https://example.com');
239 * ```
240 */
241 abstract createBrowserContext(options?: BrowserContextOptions): Promise<BrowserContext>;
242 /**
243 * Gets a list of open {@link BrowserContext | browser contexts}.
244 *
245 * In a newly-created {@link Browser | browser}, this will return a single
246 * instance of {@link BrowserContext}.
247 */
248 abstract browserContexts(): BrowserContext[];
249 /**
250 * Gets the default {@link BrowserContext | browser context}.
251 *
252 * @remarks The default {@link BrowserContext | browser context} cannot be
253 * closed.
254 */
255 abstract defaultBrowserContext(): BrowserContext;
256 /**
257 * Gets the WebSocket URL to connect to this {@link Browser | browser}.
258 *
259 * This is usually used with {@link Puppeteer.connect}.
260 *
261 * You can find the debugger URL (`webSocketDebuggerUrl`) from
262 * `http://HOST:PORT/json/version`.
263 *
264 * See {@link
265 * https://chromedevtools.github.io/devtools-protocol/#how-do-i-access-the-browser-target
266 * | browser endpoint} for more information.
267 *
268 * @remarks The format is always `ws://HOST:PORT/devtools/browser/<id>`.
269 */
270 abstract wsEndpoint(): string;
271 /**
272 * Creates a new {@link Page | page} in the
273 * {@link Browser.defaultBrowserContext | default browser context}.
274 */
275 abstract newPage(): Promise<Page>;
276 /**
277 * Gets all active {@link Target | targets}.
278 *
279 * In case of multiple {@link BrowserContext | browser contexts}, this returns
280 * all {@link Target | targets} in all
281 * {@link BrowserContext | browser contexts}.
282 */
283 abstract targets(): Target[];
284 /**
285 * Gets the {@link Target | target} associated with the
286 * {@link Browser.defaultBrowserContext | default browser context}).
287 */
288 abstract target(): Target;
289 /**
290 * Waits until a {@link Target | target} matching the given `predicate`
291 * appears and returns it.
292 *
293 * This will look all open {@link BrowserContext | browser contexts}.
294 *
295 * @example Finding a target for a page opened via `window.open`:
296 *
297 * ```ts
298 * await page.evaluate(() => window.open('https://www.example.com/'));
299 * const newWindowTarget = await browser.waitForTarget(
300 * target => target.url() === 'https://www.example.com/'
301 * );
302 * ```
303 */
304 waitForTarget(predicate: (x: Target) => boolean | Promise<boolean>, options?: WaitForTargetOptions): Promise<Target>;
305 /**
306 * Gets a list of all open {@link Page | pages} inside this {@link Browser}.
307 *
308 * If there are multiple {@link BrowserContext | browser contexts}, this
309 * returns all {@link Page | pages} in all
310 * {@link BrowserContext | browser contexts}.
311 *
312 * @remarks Non-visible {@link Page | pages}, such as `"background_page"`,
313 * will not be listed here. You can find them using {@link Target.page}.
314 */
315 pages(): Promise<Page[]>;
316 /**
317 * Gets a string representing this {@link Browser | browser's} name and
318 * version.
319 *
320 * For headless browser, this is similar to `"HeadlessChrome/61.0.3153.0"`. For
321 * non-headless or new-headless, this is similar to `"Chrome/61.0.3153.0"`. For
322 * Firefox, it is similar to `"Firefox/116.0a1"`.
323 *
324 * The format of {@link Browser.version} might change with future releases of
325 * browsers.
326 */
327 abstract version(): Promise<string>;
328 /**
329 * Gets this {@link Browser | browser's} original user agent.
330 *
331 * {@link Page | Pages} can override the user agent with
332 * {@link Page.setUserAgent}.
333 *
334 */
335 abstract userAgent(): Promise<string>;
336 /**
337 * Closes this {@link Browser | browser} and all associated
338 * {@link Page | pages}.
339 */
340 abstract close(): Promise<void>;
341 /**
342 * Disconnects Puppeteer from this {@link Browser | browser}, but leaves the
343 * process running.
344 */
345 abstract disconnect(): Promise<void>;
346 /**
347 * Whether Puppeteer is connected to this {@link Browser | browser}.
348 *
349 * @deprecated Use {@link Browser | Browser.connected}.
350 */
351 isConnected(): boolean;
352 /**
353 * Whether Puppeteer is connected to this {@link Browser | browser}.
354 */
355 abstract get connected(): boolean;
356 /* Excluded from this release type: [disposeSymbol] */
357 /* Excluded from this release type: [asyncDisposeSymbol] */
358 /* Excluded from this release type: protocol */
359 /**
360 * Get debug information from Puppeteer.
361 *
362 * @remarks
363 *
364 * Currently, includes pending protocol calls. In the future, we might add more info.
365 *
366 * @public
367 * @experimental
368 */
369 abstract get debugInfo(): DebugInfo;
370}
371
372/* Excluded from this release type: BrowserCloseCallback */
373
374/**
375 * Generic browser options that can be passed when launching any browser or when
376 * connecting to an existing browser instance.
377 * @public
378 */
379export declare interface BrowserConnectOptions {
380 /**
381 * Whether to ignore HTTPS errors during navigation.
382 * @defaultValue `false`
383 */
384 acceptInsecureCerts?: boolean;
385 /**
386 * Sets the viewport for each page.
387 *
388 * @defaultValue '\{width: 800, height: 600\}'
389 */
390 defaultViewport?: Viewport | null;
391 /**
392 * Slows down Puppeteer operations by the specified amount of milliseconds to
393 * aid debugging.
394 */
395 slowMo?: number;
396 /**
397 * Callback to decide if Puppeteer should connect to a given target or not.
398 */
399 targetFilter?: TargetFilterCallback;
400 /* Excluded from this release type: _isPageTarget */
401 /**
402 * @defaultValue Determined at run time:
403 *
404 * - Launching Chrome - 'cdp'.
405 *
406 * - Launching Firefox - 'webDriverBiDi'.
407 *
408 * - Connecting to a browser - 'cdp'.
409 *
410 * @public
411 */
412 protocol?: ProtocolType;
413 /**
414 * Timeout setting for individual protocol (CDP) calls.
415 *
416 * @defaultValue `180_000`
417 */
418 protocolTimeout?: number;
419}
420
421/**
422 * {@link BrowserContext} represents individual user contexts within a
423 * {@link Browser | browser}.
424 *
425 * When a {@link Browser | browser} is launched, it has at least one default
426 * {@link BrowserContext | browser context}. Others can be created
427 * using {@link Browser.createBrowserContext}. Each context has isolated storage
428 * (cookies/localStorage/etc.)
429 *
430 * {@link BrowserContext} {@link EventEmitter | emits} various events which are
431 * documented in the {@link BrowserContextEvent} enum.
432 *
433 * If a {@link Page | page} opens another {@link Page | page}, e.g. using
434 * `window.open`, the popup will belong to the parent {@link Page.browserContext
435 * | page's browser context}.
436 *
437 * @example Creating a new {@link BrowserContext | browser context}:
438 *
439 * ```ts
440 * // Create a new browser context
441 * const context = await browser.createBrowserContext();
442 * // Create a new page inside context.
443 * const page = await context.newPage();
444 * // ... do stuff with page ...
445 * await page.goto('https://example.com');
446 * // Dispose context once it's no longer needed.
447 * await context.close();
448 * ```
449 *
450 * @remarks
451 *
452 * In Chrome all non-default contexts are incognito,
453 * and {@link Browser.defaultBrowserContext | default browser context}
454 * might be incognito if you provide the `--incognito` argument when launching
455 * the browser.
456 *
457 * @public
458 */
459export declare abstract class BrowserContext extends EventEmitter<BrowserContextEvents> {
460 #private;
461 /* Excluded from this release type: __constructor */
462 /**
463 * Gets all active {@link Target | targets} inside this
464 * {@link BrowserContext | browser context}.
465 */
466 abstract targets(): Target[];
467 /* Excluded from this release type: startScreenshot */
468 /* Excluded from this release type: waitForScreenshotOperations */
469 /**
470 * Waits until a {@link Target | target} matching the given `predicate`
471 * appears and returns it.
472 *
473 * This will look all open {@link BrowserContext | browser contexts}.
474 *
475 * @example Finding a target for a page opened via `window.open`:
476 *
477 * ```ts
478 * await page.evaluate(() => window.open('https://www.example.com/'));
479 * const newWindowTarget = await browserContext.waitForTarget(
480 * target => target.url() === 'https://www.example.com/'
481 * );
482 * ```
483 */
484 waitForTarget(predicate: (x: Target) => boolean | Promise<boolean>, options?: WaitForTargetOptions): Promise<Target>;
485 /**
486 * Gets a list of all open {@link Page | pages} inside this
487 * {@link BrowserContext | browser context}.
488 *
489 * @remarks Non-visible {@link Page | pages}, such as `"background_page"`,
490 * will not be listed here. You can find them using {@link Target.page}.
491 */
492 abstract pages(): Promise<Page[]>;
493 /**
494 * Grants this {@link BrowserContext | browser context} the given
495 * `permissions` within the given `origin`.
496 *
497 * @example Overriding permissions in the
498 * {@link Browser.defaultBrowserContext | default browser context}:
499 *
500 * ```ts
501 * const context = browser.defaultBrowserContext();
502 * await context.overridePermissions('https://html5demos.com', [
503 * 'geolocation',
504 * ]);
505 * ```
506 *
507 * @param origin - The origin to grant permissions to, e.g.
508 * "https://example.com".
509 * @param permissions - An array of permissions to grant. All permissions that
510 * are not listed here will be automatically denied.
511 */
512 abstract overridePermissions(origin: string, permissions: Permission[]): Promise<void>;
513 /**
514 * Clears all permission overrides for this
515 * {@link BrowserContext | browser context}.
516 *
517 * @example Clearing overridden permissions in the
518 * {@link Browser.defaultBrowserContext | default browser context}:
519 *
520 * ```ts
521 * const context = browser.defaultBrowserContext();
522 * context.overridePermissions('https://example.com', ['clipboard-read']);
523 * // do stuff ..
524 * context.clearPermissionOverrides();
525 * ```
526 */
527 abstract clearPermissionOverrides(): Promise<void>;
528 /**
529 * Creates a new {@link Page | page} in this
530 * {@link BrowserContext | browser context}.
531 */
532 abstract newPage(): Promise<Page>;
533 /**
534 * Gets the {@link Browser | browser} associated with this
535 * {@link BrowserContext | browser context}.
536 */
537 abstract browser(): Browser;
538 /**
539 * Closes this {@link BrowserContext | browser context} and all associated
540 * {@link Page | pages}.
541 *
542 * @remarks The
543 * {@link Browser.defaultBrowserContext | default browser context} cannot be
544 * closed.
545 */
546 abstract close(): Promise<void>;
547 /**
548 * Whether this {@link BrowserContext | browser context} is closed.
549 */
550 get closed(): boolean;
551 /**
552 * Identifier for this {@link BrowserContext | browser context}.
553 */
554 get id(): string | undefined;
555 /* Excluded from this release type: [disposeSymbol] */
556 /* Excluded from this release type: [asyncDisposeSymbol] */
557}
558
559/**
560 * @public
561 */
562export declare const enum BrowserContextEvent {
563 /**
564 * Emitted when the url of a target inside the browser context changes.
565 * Contains a {@link Target} instance.
566 */
567 TargetChanged = "targetchanged",
568 /**
569 * Emitted when a target is created within the browser context, for example
570 * when a new page is opened by
571 * {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/open | window.open}
572 * or by {@link BrowserContext.newPage | browserContext.newPage}
573 *
574 * Contains a {@link Target} instance.
575 */
576 TargetCreated = "targetcreated",
577 /**
578 * Emitted when a target is destroyed within the browser context, for example
579 * when a page is closed. Contains a {@link Target} instance.
580 */
581 TargetDestroyed = "targetdestroyed"
582}
583
584/**
585 * @public
586 */
587export declare interface BrowserContextEvents extends Record<EventType, unknown> {
588 [BrowserContextEvent.TargetChanged]: Target;
589 [BrowserContextEvent.TargetCreated]: Target;
590 [BrowserContextEvent.TargetDestroyed]: Target;
591}
592
593/**
594 * @public
595 */
596export declare interface BrowserContextOptions {
597 /**
598 * Proxy server with optional port to use for all requests.
599 * Username and password can be set in `Page.authenticate`.
600 */
601 proxyServer?: string;
602 /**
603 * Bypass the proxy for the given list of hosts.
604 */
605 proxyBypassList?: string[];
606}
607
608/**
609 * All the events a {@link Browser | browser instance} may emit.
610 *
611 * @public
612 */
613export declare const enum BrowserEvent {
614 /**
615 * Emitted when Puppeteer gets disconnected from the browser instance. This
616 * might happen because either:
617 *
618 * - The browser closes/crashes or
619 * - {@link Browser.disconnect} was called.
620 */
621 Disconnected = "disconnected",
622 /**
623 * Emitted when the URL of a target changes. Contains a {@link Target}
624 * instance.
625 *
626 * @remarks Note that this includes target changes in all browser
627 * contexts.
628 */
629 TargetChanged = "targetchanged",
630 /**
631 * Emitted when a target is created, for example when a new page is opened by
632 * {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/open | window.open}
633 * or by {@link Browser.newPage | browser.newPage}
634 *
635 * Contains a {@link Target} instance.
636 *
637 * @remarks Note that this includes target creations in all browser
638 * contexts.
639 */
640 TargetCreated = "targetcreated",
641 /**
642 * Emitted when a target is destroyed, for example when a page is closed.
643 * Contains a {@link Target} instance.
644 *
645 * @remarks Note that this includes target destructions in all browser
646 * contexts.
647 */
648 TargetDestroyed = "targetdestroyed",
649 /* Excluded from this release type: TargetDiscovered */
650}
651
652/**
653 * @public
654 */
655export declare interface BrowserEvents extends Record<EventType, unknown> {
656 [BrowserEvent.Disconnected]: undefined;
657 [BrowserEvent.TargetCreated]: Target;
658 [BrowserEvent.TargetDestroyed]: Target;
659 [BrowserEvent.TargetChanged]: Target;
660 /* Excluded from this release type: targetdiscovered */
661}
662
663/**
664 * Launcher options that only apply to Chrome.
665 *
666 * @public
667 */
668export declare interface BrowserLaunchArgumentOptions {
669 /**
670 * Whether to run the browser in headless mode.
671 *
672 * @remarks
673 *
674 * - `true` launches the browser in the
675 * {@link https://developer.chrome.com/articles/new-headless/ | new headless}
676 * mode.
677 *
678 * - `'shell'` launches
679 * {@link https://developer.chrome.com/blog/chrome-headless-shell | shell}
680 * known as the old headless mode.
681 *
682 * @defaultValue `true`
683 */
684 headless?: boolean | 'shell';
685 /**
686 * Path to a user data directory.
687 * {@link https://chromium.googlesource.com/chromium/src/+/refs/heads/main/docs/user_data_dir.md | see the Chromium docs}
688 * for more info.
689 */
690 userDataDir?: string;
691 /**
692 * Whether to auto-open a DevTools panel for each tab. If this is set to
693 * `true`, then `headless` will be forced to `false`.
694 * @defaultValue `false`
695 */
696 devtools?: boolean;
697 /**
698 * Specify the debugging port number to use
699 */
700 debuggingPort?: number;
701 /**
702 * Additional command line arguments to pass to the browser instance.
703 */
704 args?: string[];
705}
706
707/**
708 * Describes a launcher - a class that is able to create and launch a browser instance.
709 *
710 * @public
711 */
712export declare abstract class BrowserLauncher {
713 #private;
714 /* Excluded from this release type: puppeteer */
715 /* Excluded from this release type: __constructor */
716 get browser(): SupportedBrowser;
717 launch(options?: PuppeteerNodeLaunchOptions): Promise<Browser>;
718 abstract executablePath(channel?: ChromeReleaseChannel): string;
719 abstract defaultArgs(object: BrowserLaunchArgumentOptions): string[];
720 /* Excluded from this release type: computeLaunchArguments */
721 /* Excluded from this release type: cleanUserDataDir */
722 /* Excluded from this release type: closeBrowser */
723 /* Excluded from this release type: waitForPageTarget */
724 /* Excluded from this release type: createCdpSocketConnection */
725 /* Excluded from this release type: createCdpPipeConnection */
726 /* Excluded from this release type: createBiDiOverCdpBrowser */
727 /* Excluded from this release type: createBiDiBrowser */
728 /* Excluded from this release type: getProfilePath */
729 /* Excluded from this release type: resolveExecutablePath */
730}
731
732/* Excluded from this release type: BrowserWebSocketTransport */
733
734/* Excluded from this release type: Callback */
735
736/* Excluded from this release type: CallbackRegistry */
737
738/* Excluded from this release type: CDP_BINDING_PREFIX */
739
740/* Excluded from this release type: CdpBrowser */
741
742/* Excluded from this release type: CdpBrowserContext */
743
744/* Excluded from this release type: CdpCDPSession */
745
746/* Excluded from this release type: CdpDialog */
747
748/* Excluded from this release type: CdpElementHandle */
749
750/**
751 * @public
752 */
753export declare type CDPEvents = {
754 [Property in keyof ProtocolMapping.Events]: ProtocolMapping.Events[Property][0];
755};
756
757/* Excluded from this release type: CdpFrame */
758
759/* Excluded from this release type: CdpHTTPRequest */
760
761/* Excluded from this release type: CdpHTTPResponse */
762
763/* Excluded from this release type: CdpJSHandle */
764
765/* Excluded from this release type: CdpKeyboard */
766
767/* Excluded from this release type: CdpMouse */
768
769/* Excluded from this release type: CdpPage */
770
771/* Excluded from this release type: CdpPreloadScript */
772
773/**
774 * The `CDPSession` instances are used to talk raw Chrome Devtools Protocol.
775 *
776 * @remarks
777 *
778 * Protocol methods can be called with {@link CDPSession.send} method and protocol
779 * events can be subscribed to with `CDPSession.on` method.
780 *
781 * Useful links: {@link https://chromedevtools.github.io/devtools-protocol/ | DevTools Protocol Viewer}
782 * and {@link https://github.com/aslushnikov/getting-started-with-cdp/blob/HEAD/README.md | Getting Started with DevTools Protocol}.
783 *
784 * @example
785 *
786 * ```ts
787 * const client = await page.createCDPSession();
788 * await client.send('Animation.enable');
789 * client.on('Animation.animationCreated', () =>
790 * console.log('Animation created!')
791 * );
792 * const response = await client.send('Animation.getPlaybackRate');
793 * console.log('playback rate is ' + response.playbackRate);
794 * await client.send('Animation.setPlaybackRate', {
795 * playbackRate: response.playbackRate / 2,
796 * });
797 * ```
798 *
799 * @public
800 */
801export declare abstract class CDPSession extends EventEmitter<CDPSessionEvents> {
802 /* Excluded from this release type: __constructor */
803 abstract connection(): Connection | undefined;
804 /* Excluded from this release type: parentSession */
805 abstract send<T extends keyof ProtocolMapping.Commands>(method: T, params?: ProtocolMapping.Commands[T]['paramsType'][0], options?: CommandOptions): Promise<ProtocolMapping.Commands[T]['returnType']>;
806 /**
807 * Detaches the cdpSession from the target. Once detached, the cdpSession object
808 * won't emit any events and can't be used to send messages.
809 */
810 abstract detach(): Promise<void>;
811 /**
812 * Returns the session's id.
813 */
814 abstract id(): string;
815}
816
817/**
818 * Events that the CDPSession class emits.
819 *
820 * @public
821 */
822export declare namespace CDPSessionEvent {
823 /* Excluded from this release type: Disconnected */
824 /* Excluded from this release type: Swapped */
825 /* Excluded from this release type: Ready */
826 const SessionAttached: "sessionattached";
827 const SessionDetached: "sessiondetached";
828}
829
830/**
831 * @public
832 */
833export declare interface CDPSessionEvents extends CDPEvents, Record<EventType, unknown> {
834 /* Excluded from this release type: [CDPSessionEvent.Disconnected] */
835 /* Excluded from this release type: [CDPSessionEvent.Swapped] */
836 /* Excluded from this release type: [CDPSessionEvent.Ready] */
837 [CDPSessionEvent.SessionAttached]: CDPSession;
838 [CDPSessionEvent.SessionDetached]: CDPSession;
839}
840
841/* Excluded from this release type: CdpTarget */
842
843/* Excluded from this release type: CdpTouchscreen */
844
845/* Excluded from this release type: CdpWebWorker */
846
847/**
848 * @public
849 */
850export declare interface ChromeHeadlessShellSettings {
851 /**
852 * Tells Puppeteer to not download the browser during installation.
853 *
854 * Can be overridden by `PUPPETEER_CHROME_HEADLESS_SHELL_SKIP_DOWNLOAD`
855 * or `PUPPETEER_SKIP_CHROME_HEADLESS_SHELL_DOWNLOAD`.
856 *
857 * @defaultValue false
858 */
859 skipDownload?: boolean;
860 /**
861 * Specifies the URL prefix that is used to download the browser.
862 *
863 * Can be overridden by `PUPPETEER_CHROME_HEADLESS_SHELL_DOWNLOAD_BASE_URL`.
864 *
865 * @remarks
866 * This must include the protocol and may even need a path prefix.
867 * This must **not** include a trailing slash similar to the default.
868 *
869 * @defaultValue https://storage.googleapis.com/chrome-for-testing-public
870 */
871 downloadBaseUrl?: string;
872 /**
873 * Specifies a certain version of the browser you'd like Puppeteer to use.
874 *
875 * Can be overridden by `PUPPETEER_CHROME_HEADLESS_SHELL_VERSION`.
876 *
877 * See {@link PuppeteerNode.launch | puppeteer.launch} on how executable path
878 * is inferred.
879 *
880 * @example 119.0.6045.105
881 * @defaultValue The pinned browser version supported by the current Puppeteer
882 * version.
883 */
884 version?: string;
885}
886
887/* Excluded from this release type: ChromeLauncher */
888
889/**
890 * @public
891 */
892export declare type ChromeReleaseChannel = 'chrome' | 'chrome-beta' | 'chrome-canary' | 'chrome-dev';
893
894/**
895 * @public
896 */
897export declare interface ChromeSettings {
898 /**
899 * Tells Puppeteer to not download the browser during installation.
900 *
901 * Can be overridden by `PUPPETEER_CHROME_SKIP_DOWNLOAD`.
902 *
903 * @defaultValue false
904 */
905 skipDownload?: boolean;
906 /**
907 * Specifies the URL prefix that is used to download the browser.
908 *
909 * Can be overridden by `PUPPETEER_CHROME_DOWNLOAD_BASE_URL`.
910 *
911 * @remarks
912 * This must include the protocol and may even need a path prefix.
913 * This must **not** include a trailing slash similar to the default.
914 *
915 * @defaultValue https://storage.googleapis.com/chrome-for-testing-public
916 */
917 downloadBaseUrl?: string;
918 /**
919 * Specifies a certain version of the browser you'd like Puppeteer to use.
920 *
921 * Can be overridden by `PUPPETEER_CHROME_VERSION`
922 * or `PUPPETEER_SKIP_CHROME_DOWNLOAD`.
923 *
924 * See {@link PuppeteerNode.launch | puppeteer.launch} on how executable path
925 * is inferred.
926 *
927 * @example 119.0.6045.105
928 * @defaultValue The pinned browser version supported by the current Puppeteer
929 * version.
930 */
931 version?: string;
932}
933
934/* Excluded from this release type: ChromeTargetManager */
935
936/**
937 * @public
938 */
939export declare interface ClickOptions extends MouseClickOptions {
940 /**
941 * Offset for the clickable point relative to the top-left corner of the border box.
942 */
943 offset?: Offset;
944}
945
946/* Excluded from this release type: ClientProvider */
947
948/**
949 * @public
950 */
951export declare interface CommandOptions {
952 timeout: number;
953}
954
955/**
956 * @public
957 */
958export declare interface CommonEventEmitter<Events extends Record<EventType, unknown>> {
959 on<Key extends keyof Events>(type: Key, handler: Handler<Events[Key]>): this;
960 off<Key extends keyof Events>(type: Key, handler?: Handler<Events[Key]>): this;
961 emit<Key extends keyof Events>(type: Key, event: Events[Key]): boolean;
962 once<Key extends keyof Events>(type: Key, handler: Handler<Events[Key]>): this;
963 listenerCount(event: keyof Events): number;
964 removeAllListeners(event?: keyof Events): this;
965}
966
967/* Excluded from this release type: CommonPuppeteerSettings */
968
969/* Excluded from this release type: ComplexPSelector */
970
971/* Excluded from this release type: ComplexPSelectorList */
972
973/* Excluded from this release type: CompoundPSelector */
974
975/**
976 * Defines options to configure Puppeteer's behavior during installation and
977 * runtime.
978 *
979 * See individual properties for more information.
980 *
981 * @public
982 */
983export declare interface Configuration {
984 /**
985 * Defines the directory to be used by Puppeteer for caching.
986 *
987 * Can be overridden by `PUPPETEER_CACHE_DIR`.
988 *
989 * @defaultValue `path.join(os.homedir(), '.cache', 'puppeteer')`
990 */
991 cacheDirectory?: string;
992 /**
993 * Specifies an executable path to be used in
994 * {@link PuppeteerNode.launch | puppeteer.launch}.
995 *
996 * Can be overridden by `PUPPETEER_EXECUTABLE_PATH`.
997 *
998 * @defaultValue **Auto-computed.**
999 */
1000 executablePath?: string;
1001 /**
1002 * Specifies which browser you'd like Puppeteer to use.
1003 *
1004 * Can be overridden by `PUPPETEER_BROWSER`.
1005 *
1006 * @defaultValue `chrome`
1007 */
1008 defaultBrowser?: SupportedBrowser;
1009 /**
1010 * Defines the directory to be used by Puppeteer for creating temporary files.
1011 *
1012 * Can be overridden by `PUPPETEER_TMP_DIR`.
1013 *
1014 * @defaultValue `os.tmpdir()`
1015 */
1016 temporaryDirectory?: string;
1017 /**
1018 * Tells Puppeteer to not download during installation.
1019 *
1020 * Can be overridden by `PUPPETEER_SKIP_DOWNLOAD`.
1021 */
1022 skipDownload?: boolean;
1023 /**
1024 * Tells Puppeteer to log at the given level.
1025 *
1026 * @defaultValue `warn`
1027 */
1028 logLevel?: 'silent' | 'error' | 'warn';
1029 /**
1030 * Defines experimental options for Puppeteer.
1031 */
1032 experiments?: ExperimentsConfiguration;
1033 chrome?: ChromeSettings;
1034 ['chrome-headless-shell']?: ChromeHeadlessShellSettings;
1035 firefox?: FirefoxSettings;
1036}
1037
1038/**
1039 * @public
1040 */
1041export declare const
1042/**
1043* @public
1044*/
1045/**
1046 * @public
1047 */
1048connect: (options: ConnectOptions) => Promise<Browser>;
1049
1050/**
1051 * @public
1052 */
1053export declare class Connection extends EventEmitter<CDPSessionEvents> {
1054 #private;
1055 constructor(url: string, transport: ConnectionTransport, delay?: number, timeout?: number);
1056 static fromSession(session: CDPSession): Connection | undefined;
1057 /* Excluded from this release type: delay */
1058 get timeout(): number;
1059 /* Excluded from this release type: _closed */
1060 /* Excluded from this release type: _sessions */
1061 /**
1062 * @param sessionId - The session id
1063 * @returns The current CDP session if it exists
1064 */
1065 session(sessionId: string): CDPSession | null;
1066 url(): string;
1067 send<T extends keyof ProtocolMapping.Commands>(method: T, params?: ProtocolMapping.Commands[T]['paramsType'][0], options?: CommandOptions): Promise<ProtocolMapping.Commands[T]['returnType']>;
1068 /* Excluded from this release type: _rawSend */
1069 /* Excluded from this release type: closeBrowser */
1070 /* Excluded from this release type: onMessage */
1071 dispose(): void;
1072 /* Excluded from this release type: isAutoAttached */
1073 /* Excluded from this release type: _createSession */
1074 /**
1075 * @param targetInfo - The target info
1076 * @returns The CDP session that is created
1077 */
1078 createSession(targetInfo: Protocol.Target.TargetInfo): Promise<CDPSession>;
1079 /* Excluded from this release type: getPendingProtocolErrors */
1080}
1081
1082/**
1083 * @license
1084 * Copyright 2020 Google Inc.
1085 * SPDX-License-Identifier: Apache-2.0
1086 */
1087/**
1088 * @public
1089 */
1090export declare interface ConnectionTransport {
1091 send(message: string): void;
1092 close(): void;
1093 onmessage?: (message: string) => void;
1094 onclose?: () => void;
1095}
1096
1097/**
1098 * @public
1099 */
1100export declare interface ConnectOptions extends BrowserConnectOptions {
1101 browserWSEndpoint?: string;
1102 browserURL?: string;
1103 transport?: ConnectionTransport;
1104 /**
1105 * Headers to use for the web socket connection.
1106 * @remarks
1107 * Only works in the Node.js environment.
1108 */
1109 headers?: Record<string, string>;
1110 /**
1111 * WebDriver BiDi capabilities passed to BiDi `session.new`.
1112 *
1113 * @remarks
1114 * Only works for `protocol="webDriverBiDi"` and {@link Puppeteer.connect}.
1115 */
1116 capabilities?: SupportedWebDriverCapabilities;
1117}
1118
1119/* Excluded from this release type: _connectToCdpBrowser */
1120
1121/* Excluded from this release type: ConsoleAPICalledCallback */
1122
1123/**
1124 * ConsoleMessage objects are dispatched by page via the 'console' event.
1125 * @public
1126 */
1127export declare class ConsoleMessage {
1128 #private;
1129 /* Excluded from this release type: __constructor */
1130 /**
1131 * The type of the console message.
1132 */
1133 type(): ConsoleMessageType;
1134 /**
1135 * The text of the console message.
1136 */
1137 text(): string;
1138 /**
1139 * An array of arguments passed to the console.
1140 */
1141 args(): JSHandle[];
1142 /**
1143 * The location of the console message.
1144 */
1145 location(): ConsoleMessageLocation;
1146 /**
1147 * The array of locations on the stack of the console message.
1148 */
1149 stackTrace(): ConsoleMessageLocation[];
1150}
1151
1152/**
1153 * @public
1154 */
1155export declare interface ConsoleMessageLocation {
1156 /**
1157 * URL of the resource if known or `undefined` otherwise.
1158 */
1159 url?: string;
1160 /**
1161 * 0-based line number in the resource if known or `undefined` otherwise.
1162 */
1163 lineNumber?: number;
1164 /**
1165 * 0-based column number in the resource if known or `undefined` otherwise.
1166 */
1167 columnNumber?: number;
1168}
1169
1170/**
1171 * The supported types for console messages.
1172 * @public
1173 */
1174export declare type ConsoleMessageType = 'log' | 'debug' | 'info' | 'error' | 'warn' | 'dir' | 'dirxml' | 'table' | 'trace' | 'clear' | 'startGroup' | 'startGroupCollapsed' | 'endGroup' | 'assert' | 'profile' | 'profileEnd' | 'count' | 'timeEnd' | 'verbose';
1175
1176/**
1177 * @public
1178 */
1179export declare interface ContinueRequestOverrides {
1180 /**
1181 * If set, the request URL will change. This is not a redirect.
1182 */
1183 url?: string;
1184 method?: string;
1185 postData?: string;
1186 headers?: Record<string, string>;
1187}
1188
1189/**
1190 * Represents a cookie object.
1191 *
1192 * @public
1193 */
1194export declare interface Cookie {
1195 /**
1196 * Cookie name.
1197 */
1198 name: string;
1199 /**
1200 * Cookie value.
1201 */
1202 value: string;
1203 /**
1204 * Cookie domain.
1205 */
1206 domain: string;
1207 /**
1208 * Cookie path.
1209 */
1210 path: string;
1211 /**
1212 * Cookie expiration date as the number of seconds since the UNIX epoch. Set to `-1` for
1213 * session cookies
1214 */
1215 expires: number;
1216 /**
1217 * Cookie size.
1218 */
1219 size: number;
1220 /**
1221 * True if cookie is http-only.
1222 */
1223 httpOnly: boolean;
1224 /**
1225 * True if cookie is secure.
1226 */
1227 secure: boolean;
1228 /**
1229 * True in case of session cookie.
1230 */
1231 session: boolean;
1232 /**
1233 * Cookie SameSite type.
1234 */
1235 sameSite?: CookieSameSite;
1236 /**
1237 * Cookie Priority. Supported only in Chrome.
1238 */
1239 priority?: CookiePriority;
1240 /**
1241 * True if cookie is SameParty. Supported only in Chrome.
1242 */
1243 sameParty?: boolean;
1244 /**
1245 * Cookie source scheme type. Supported only in Chrome.
1246 */
1247 sourceScheme?: CookieSourceScheme;
1248 /**
1249 * Cookie partition key. In Chrome, it is the top-level site the
1250 * partitioned cookie is available in. In Firefox, it matches the
1251 * source origin
1252 * (https://w3c.github.io/webdriver-bidi/#type-storage-PartitionKey).
1253 */
1254 partitionKey?: string;
1255 /**
1256 * True if cookie partition key is opaque. Supported only in Chrome.
1257 */
1258 partitionKeyOpaque?: boolean;
1259}
1260
1261/**
1262 * Cookie parameter object
1263 *
1264 * @public
1265 */
1266export declare interface CookieParam {
1267 /**
1268 * Cookie name.
1269 */
1270 name: string;
1271 /**
1272 * Cookie value.
1273 */
1274 value: string;
1275 /**
1276 * The request-URI to associate with the setting of the cookie. This value can affect
1277 * the default domain, path, and source scheme values of the created cookie.
1278 */
1279 url?: string;
1280 /**
1281 * Cookie domain.
1282 */
1283 domain?: string;
1284 /**
1285 * Cookie path.
1286 */
1287 path?: string;
1288 /**
1289 * True if cookie is secure.
1290 */
1291 secure?: boolean;
1292 /**
1293 * True if cookie is http-only.
1294 */
1295 httpOnly?: boolean;
1296 /**
1297 * Cookie SameSite type.
1298 */
1299 sameSite?: CookieSameSite;
1300 /**
1301 * Cookie expiration date, session cookie if not set
1302 */
1303 expires?: number;
1304 /**
1305 * Cookie Priority. Supported only in Chrome.
1306 */
1307 priority?: CookiePriority;
1308 /**
1309 * True if cookie is SameParty. Supported only in Chrome.
1310 */
1311 sameParty?: boolean;
1312 /**
1313 * Cookie source scheme type. Supported only in Chrome.
1314 */
1315 sourceScheme?: CookieSourceScheme;
1316 /**
1317 * Cookie partition key. In Chrome, it matches the top-level site the
1318 * partitioned cookie is available in. In Firefox, it matches the
1319 * source origin
1320 * (https://w3c.github.io/webdriver-bidi/#type-storage-PartitionKey).
1321 */
1322 partitionKey?: string;
1323}
1324
1325/**
1326 * Represents the cookie's 'Priority' status:
1327 * https://tools.ietf.org/html/draft-west-cookie-priority-00
1328 *
1329 * @public
1330 */
1331export declare type CookiePriority = 'Low' | 'Medium' | 'High';
1332
1333/**
1334 * @license
1335 * Copyright 2024 Google Inc.
1336 * SPDX-License-Identifier: Apache-2.0
1337 */
1338/**
1339 * Represents the cookie's 'SameSite' status:
1340 * https://tools.ietf.org/html/draft-west-first-party-cookies
1341 *
1342 * @public
1343 */
1344export declare type CookieSameSite = 'Strict' | 'Lax' | 'None';
1345
1346/**
1347 * Represents the source scheme of the origin that originally set the cookie. A value of
1348 * "Unset" allows protocol clients to emulate legacy cookie scope for the scheme.
1349 * This is a temporary ability and it will be removed in the future.
1350 *
1351 * @public
1352 */
1353export declare type CookieSourceScheme = 'Unset' | 'NonSecure' | 'Secure';
1354
1355/**
1356 * The Coverage class provides methods to gather information about parts of
1357 * JavaScript and CSS that were used by the page.
1358 *
1359 * @remarks
1360 * To output coverage in a form consumable by {@link https://github.com/istanbuljs | Istanbul},
1361 * see {@link https://github.com/istanbuljs/puppeteer-to-istanbul | puppeteer-to-istanbul}.
1362 *
1363 * @example
1364 * An example of using JavaScript and CSS coverage to get percentage of initially
1365 * executed code:
1366 *
1367 * ```ts
1368 * // Enable both JavaScript and CSS coverage
1369 * await Promise.all([
1370 * page.coverage.startJSCoverage(),
1371 * page.coverage.startCSSCoverage(),
1372 * ]);
1373 * // Navigate to page
1374 * await page.goto('https://example.com');
1375 * // Disable both JavaScript and CSS coverage
1376 * const [jsCoverage, cssCoverage] = await Promise.all([
1377 * page.coverage.stopJSCoverage(),
1378 * page.coverage.stopCSSCoverage(),
1379 * ]);
1380 * let totalBytes = 0;
1381 * let usedBytes = 0;
1382 * const coverage = [...jsCoverage, ...cssCoverage];
1383 * for (const entry of coverage) {
1384 * totalBytes += entry.text.length;
1385 * for (const range of entry.ranges) usedBytes += range.end - range.start - 1;
1386 * }
1387 * console.log(`Bytes used: ${(usedBytes / totalBytes) * 100}%`);
1388 * ```
1389 *
1390 * @public
1391 */
1392export declare class Coverage {
1393 #private;
1394 /* Excluded from this release type: __constructor */
1395 /* Excluded from this release type: updateClient */
1396 /**
1397 * @param options - Set of configurable options for coverage defaults to
1398 * `resetOnNavigation : true, reportAnonymousScripts : false,`
1399 * `includeRawScriptCoverage : false, useBlockCoverage : true`
1400 * @returns Promise that resolves when coverage is started.
1401 *
1402 * @remarks
1403 * Anonymous scripts are ones that don't have an associated url. These are
1404 * scripts that are dynamically created on the page using `eval` or
1405 * `new Function`. If `reportAnonymousScripts` is set to `true`, anonymous
1406 * scripts URL will start with `debugger://VM` (unless a magic //# sourceURL
1407 * comment is present, in which case that will the be URL).
1408 */
1409 startJSCoverage(options?: JSCoverageOptions): Promise<void>;
1410 /**
1411 * Promise that resolves to the array of coverage reports for
1412 * all scripts.
1413 *
1414 * @remarks
1415 * JavaScript Coverage doesn't include anonymous scripts by default.
1416 * However, scripts with sourceURLs are reported.
1417 */
1418 stopJSCoverage(): Promise<JSCoverageEntry[]>;
1419 /**
1420 * @param options - Set of configurable options for coverage, defaults to
1421 * `resetOnNavigation : true`
1422 * @returns Promise that resolves when coverage is started.
1423 */
1424 startCSSCoverage(options?: CSSCoverageOptions): Promise<void>;
1425 /**
1426 * Promise that resolves to the array of coverage reports
1427 * for all stylesheets.
1428 *
1429 * @remarks
1430 * CSS Coverage doesn't include dynamically injected style tags
1431 * without sourceURLs.
1432 */
1433 stopCSSCoverage(): Promise<CoverageEntry[]>;
1434}
1435
1436/**
1437 * The CoverageEntry class represents one entry of the coverage report.
1438 * @public
1439 */
1440export declare interface CoverageEntry {
1441 /**
1442 * The URL of the style sheet or script.
1443 */
1444 url: string;
1445 /**
1446 * The content of the style sheet or script.
1447 */
1448 text: string;
1449 /**
1450 * The covered range as start and end positions.
1451 */
1452 ranges: Array<{
1453 start: number;
1454 end: number;
1455 }>;
1456}
1457
1458/* Excluded from this release type: createClientError */
1459
1460/* Excluded from this release type: createEvaluationError */
1461
1462/* Excluded from this release type: createIncrementalIdGenerator */
1463
1464/* Excluded from this release type: createProtocolErrorMessage */
1465
1466/**
1467 * @public
1468 */
1469export declare interface Credentials {
1470 username: string;
1471 password: string;
1472}
1473
1474/**
1475 * @public
1476 */
1477export declare class CSSCoverage {
1478 #private;
1479 constructor(client: CDPSession);
1480 /* Excluded from this release type: updateClient */
1481 start(options?: {
1482 resetOnNavigation?: boolean;
1483 }): Promise<void>;
1484 stop(): Promise<CoverageEntry[]>;
1485}
1486
1487/**
1488 * Set of configurable options for CSS coverage.
1489 * @public
1490 */
1491export declare interface CSSCoverageOptions {
1492 /**
1493 * Whether to reset coverage on every navigation.
1494 */
1495 resetOnNavigation?: boolean;
1496}
1497
1498/* Excluded from this release type: CSSSelector */
1499
1500/**
1501 * @public
1502 */
1503export declare interface CustomQueryHandler {
1504 /**
1505 * Searches for a {@link https://developer.mozilla.org/en-US/docs/Web/API/Node | Node} matching the given `selector` from {@link https://developer.mozilla.org/en-US/docs/Web/API/Node | node}.
1506 */
1507 queryOne?: (node: Node, selector: string) => Node | null;
1508 /**
1509 * Searches for some {@link https://developer.mozilla.org/en-US/docs/Web/API/Node | Nodes} matching the given `selector` from {@link https://developer.mozilla.org/en-US/docs/Web/API/Node | node}.
1510 */
1511 queryAll?: (node: Node, selector: string) => Iterable<Node>;
1512}
1513
1514/* Excluded from this release type: CustomQueryHandlerRegistry */
1515
1516/* Excluded from this release type: customQueryHandlers */
1517
1518declare interface CustomQuerySelector {
1519 querySelector(root: Node, selector: string): Awaitable<Node | null>;
1520 querySelectorAll(root: Node, selector: string): AwaitableIterable<Node>;
1521}
1522
1523/**
1524 * This class mimics the injected {@link CustomQuerySelectorRegistry}.
1525 */
1526declare class CustomQuerySelectorRegistry {
1527 #private;
1528 register(name: string, handler: CustomQueryHandler): void;
1529 unregister(name: string): void;
1530 get(name: string): CustomQuerySelector | undefined;
1531 clear(): void;
1532}
1533
1534declare namespace CustomQuerySelectors {
1535 export {
1536 CustomQuerySelector,
1537 customQuerySelectors
1538 }
1539}
1540
1541declare const customQuerySelectors: CustomQuerySelectorRegistry;
1542
1543/* Excluded from this release type: debug_2 */
1544
1545/* Excluded from this release type: debugError */
1546
1547/**
1548 * @public
1549 * @experimental
1550 */
1551export declare interface DebugInfo {
1552 pendingProtocolErrors: Error[];
1553}
1554
1555/**
1556 * The default cooperative request interception resolution priority
1557 *
1558 * @public
1559 */
1560export declare const DEFAULT_INTERCEPT_RESOLUTION_PRIORITY = 0;
1561
1562/* Excluded from this release type: DEFAULT_VIEWPORT */
1563
1564/**
1565 * @public
1566 */
1567export declare const
1568/**
1569* @public
1570*/
1571/**
1572 * @public
1573 */
1574defaultArgs: (options?: BrowserLaunchArgumentOptions | undefined) => string[];
1575
1576/* Excluded from this release type: Deferred */
1577
1578/* Excluded from this release type: DeferredOptions */
1579
1580/* Excluded from this release type: DelegatedLocator */
1581
1582/**
1583 * @public
1584 */
1585export declare interface DeleteCookiesRequest {
1586 /**
1587 * Name of the cookies to remove.
1588 */
1589 name: string;
1590 /**
1591 * If specified, deletes all the cookies with the given name where domain and path match
1592 * provided URL. Otherwise, deletes only cookies related to the current page's domain.
1593 */
1594 url?: string;
1595 /**
1596 * If specified, deletes only cookies with the exact domain.
1597 */
1598 domain?: string;
1599 /**
1600 * If specified, deletes only cookies with the exact path.
1601 */
1602 path?: string;
1603 /**
1604 * If specified, deletes cookies in the given partition key. In
1605 * Chrome, partitionKey matches the top-level site the partitioned
1606 * cookie is available in. In Firefox, it matches the source origin
1607 * (https://w3c.github.io/webdriver-bidi/#type-storage-PartitionKey).
1608 */
1609 partitionKey?: string;
1610}
1611
1612/**
1613 * @public
1614 */
1615export declare interface Device {
1616 userAgent: string;
1617 viewport: Viewport;
1618}
1619
1620/**
1621 * Device request prompts let you respond to the page requesting for a device
1622 * through an API like WebBluetooth.
1623 *
1624 * @remarks
1625 * `DeviceRequestPrompt` instances are returned via the
1626 * {@link Page.waitForDevicePrompt} method.
1627 *
1628 * @example
1629 *
1630 * ```ts
1631 * const [devicePrompt] = Promise.all([
1632 * page.waitForDevicePrompt(),
1633 * page.click('#connect-bluetooth'),
1634 * ]);
1635 * await devicePrompt.select(
1636 * await devicePrompt.waitForDevice(({name}) => name.includes('My Device'))
1637 * );
1638 * ```
1639 *
1640 * @public
1641 */
1642export declare class DeviceRequestPrompt {
1643 #private;
1644 /**
1645 * Current list of selectable devices.
1646 */
1647 devices: DeviceRequestPromptDevice[];
1648 /* Excluded from this release type: __constructor */
1649 /**
1650 * Resolve to the first device in the prompt matching a filter.
1651 */
1652 waitForDevice(filter: (device: DeviceRequestPromptDevice) => boolean, options?: WaitTimeoutOptions): Promise<DeviceRequestPromptDevice>;
1653 /**
1654 * Select a device in the prompt's list.
1655 */
1656 select(device: DeviceRequestPromptDevice): Promise<void>;
1657 /**
1658 * Cancel the prompt.
1659 */
1660 cancel(): Promise<void>;
1661}
1662
1663/**
1664 * Device in a request prompt.
1665 *
1666 * @public
1667 */
1668export declare class DeviceRequestPromptDevice {
1669 /**
1670 * Device id during a prompt.
1671 */
1672 id: string;
1673 /**
1674 * Device name as it appears in a prompt.
1675 */
1676 name: string;
1677 /* Excluded from this release type: __constructor */
1678}
1679
1680/* Excluded from this release type: DeviceRequestPromptManager */
1681
1682/* Excluded from this release type: DevToolsTarget */
1683
1684/**
1685 * Dialog instances are dispatched by the {@link Page} via the `dialog` event.
1686 *
1687 * @remarks
1688 *
1689 * @example
1690 *
1691 * ```ts
1692 * import puppeteer from 'puppeteer';
1693 *
1694 * (async () => {
1695 * const browser = await puppeteer.launch();
1696 * const page = await browser.newPage();
1697 * page.on('dialog', async dialog => {
1698 * console.log(dialog.message());
1699 * await dialog.dismiss();
1700 * await browser.close();
1701 * });
1702 * page.evaluate(() => alert('1'));
1703 * })();
1704 * ```
1705 *
1706 * @public
1707 */
1708export declare abstract class Dialog {
1709 #private;
1710 /* Excluded from this release type: handled */
1711 /* Excluded from this release type: __constructor */
1712 /**
1713 * The type of the dialog.
1714 */
1715 type(): Protocol.Page.DialogType;
1716 /**
1717 * The message displayed in the dialog.
1718 */
1719 message(): string;
1720 /**
1721 * The default value of the prompt, or an empty string if the dialog
1722 * is not a `prompt`.
1723 */
1724 defaultValue(): string;
1725 /* Excluded from this release type: handle */
1726 /**
1727 * A promise that resolves when the dialog has been accepted.
1728 *
1729 * @param promptText - optional text that will be entered in the dialog
1730 * prompt. Has no effect if the dialog's type is not `prompt`.
1731 *
1732 */
1733 accept(promptText?: string): Promise<void>;
1734 /**
1735 * A promise which will resolve once the dialog has been dismissed
1736 */
1737 dismiss(): Promise<void>;
1738}
1739
1740/* Excluded from this release type: DisposableStack */
1741
1742/* Excluded from this release type: Disposed */
1743
1744/* Excluded from this release type: disposeSymbol */
1745
1746/**
1747 * @public
1748 */
1749export declare type ElementFor<TagName extends keyof HTMLElementTagNameMap | keyof SVGElementTagNameMap> = TagName extends keyof HTMLElementTagNameMap ? HTMLElementTagNameMap[TagName] : TagName extends keyof SVGElementTagNameMap ? SVGElementTagNameMap[TagName] : never;
1750
1751/**
1752 * ElementHandle represents an in-page DOM element.
1753 *
1754 * @remarks
1755 * ElementHandles can be created with the {@link Page.$} method.
1756 *
1757 * ```ts
1758 * import puppeteer from 'puppeteer';
1759 *
1760 * (async () => {
1761 * const browser = await puppeteer.launch();
1762 * const page = await browser.newPage();
1763 * await page.goto('https://example.com');
1764 * const hrefElement = await page.$('a');
1765 * await hrefElement.click();
1766 * // ...
1767 * })();
1768 * ```
1769 *
1770 * ElementHandle prevents the DOM element from being garbage-collected unless the
1771 * handle is {@link JSHandle.dispose | disposed}. ElementHandles are auto-disposed
1772 * when their origin frame gets navigated.
1773 *
1774 * ElementHandle instances can be used as arguments in {@link Page.$eval} and
1775 * {@link Page.evaluate} methods.
1776 *
1777 * If you're using TypeScript, ElementHandle takes a generic argument that
1778 * denotes the type of element the handle is holding within. For example, if you
1779 * have a handle to a `<select>` element, you can type it as
1780 * `ElementHandle<HTMLSelectElement>` and you get some nicer type checks.
1781 *
1782 * @public
1783 */
1784export declare abstract class ElementHandle<ElementType extends Node = Element> extends JSHandle<ElementType> {
1785 #private;
1786 /* Excluded from this release type: [_isElementHandle] */
1787 /* Excluded from this release type: isolatedHandle */
1788 /* Excluded from this release type: bindIsolatedHandle */
1789 /* Excluded from this release type: handle */
1790 /* Excluded from this release type: __constructor */
1791 /* Excluded from this release type: id */
1792 /* Excluded from this release type: disposed */
1793 /* Excluded from this release type: getProperty */
1794 /* Excluded from this release type: getProperties */
1795 /* Excluded from this release type: evaluate */
1796 /* Excluded from this release type: evaluateHandle */
1797 /* Excluded from this release type: jsonValue */
1798 /* Excluded from this release type: toString */
1799 /* Excluded from this release type: remoteObject */
1800 /* Excluded from this release type: dispose */
1801 /* Excluded from this release type: asElement */
1802 /**
1803 * Frame corresponding to the current handle.
1804 */
1805 abstract get frame(): Frame;
1806 /**
1807 * Queries the current element for an element matching the given selector.
1808 *
1809 * @param selector -
1810 * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
1811 * to query the page for.
1812 * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
1813 * can be passed as-is and a
1814 * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
1815 * allows quering by
1816 * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
1817 * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
1818 * and
1819 * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
1820 * and
1821 * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
1822 * Alternatively, you can specify the selector type using a
1823 * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
1824 * @returns A {@link ElementHandle | element handle} to the first element
1825 * matching the given selector. Otherwise, `null`.
1826 */
1827 $<Selector extends string>(selector: Selector): Promise<ElementHandle<NodeFor<Selector>> | null>;
1828 /**
1829 * Queries the current element for all elements matching the given selector.
1830 *
1831 * @param selector -
1832 * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
1833 * to query the page for.
1834 * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
1835 * can be passed as-is and a
1836 * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
1837 * allows quering by
1838 * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
1839 * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
1840 * and
1841 * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
1842 * and
1843 * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
1844 * Alternatively, you can specify the selector type using a
1845 * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
1846 * @returns An array of {@link ElementHandle | element handles} that point to
1847 * elements matching the given selector.
1848 */
1849 $$<Selector extends string>(selector: Selector, options?: QueryOptions): Promise<Array<ElementHandle<NodeFor<Selector>>>>;
1850 /**
1851 * Runs the given function on the first element matching the given selector in
1852 * the current element.
1853 *
1854 * If the given function returns a promise, then this method will wait till
1855 * the promise resolves.
1856 *
1857 * @example
1858 *
1859 * ```ts
1860 * const tweetHandle = await page.$('.tweet');
1861 * expect(await tweetHandle.$eval('.like', node => node.innerText)).toBe(
1862 * '100'
1863 * );
1864 * expect(await tweetHandle.$eval('.retweets', node => node.innerText)).toBe(
1865 * '10'
1866 * );
1867 * ```
1868 *
1869 * @param selector -
1870 * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
1871 * to query the page for.
1872 * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
1873 * can be passed as-is and a
1874 * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
1875 * allows quering by
1876 * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
1877 * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
1878 * and
1879 * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
1880 * and
1881 * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
1882 * Alternatively, you can specify the selector type using a
1883 * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
1884 * @param pageFunction - The function to be evaluated in this element's page's
1885 * context. The first element matching the selector will be passed in as the
1886 * first argument.
1887 * @param args - Additional arguments to pass to `pageFunction`.
1888 * @returns A promise to the result of the function.
1889 */
1890 $eval<Selector extends string, Params extends unknown[], Func extends EvaluateFuncWith<NodeFor<Selector>, Params> = EvaluateFuncWith<NodeFor<Selector>, Params>>(selector: Selector, pageFunction: Func | string, ...args: Params): Promise<Awaited<ReturnType<Func>>>;
1891 /**
1892 * Runs the given function on an array of elements matching the given selector
1893 * in the current element.
1894 *
1895 * If the given function returns a promise, then this method will wait till
1896 * the promise resolves.
1897 *
1898 * @example
1899 * HTML:
1900 *
1901 * ```html
1902 * <div class="feed">
1903 * <div class="tweet">Hello!</div>
1904 * <div class="tweet">Hi!</div>
1905 * </div>
1906 * ```
1907 *
1908 * JavaScript:
1909 *
1910 * ```ts
1911 * const feedHandle = await page.$('.feed');
1912 * expect(
1913 * await feedHandle.$$eval('.tweet', nodes => nodes.map(n => n.innerText))
1914 * ).toEqual(['Hello!', 'Hi!']);
1915 * ```
1916 *
1917 * @param selector -
1918 * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
1919 * to query the page for.
1920 * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
1921 * can be passed as-is and a
1922 * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
1923 * allows quering by
1924 * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
1925 * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
1926 * and
1927 * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
1928 * and
1929 * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
1930 * Alternatively, you can specify the selector type using a
1931 * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
1932 * @param pageFunction - The function to be evaluated in the element's page's
1933 * context. An array of elements matching the given selector will be passed to
1934 * the function as its first argument.
1935 * @param args - Additional arguments to pass to `pageFunction`.
1936 * @returns A promise to the result of the function.
1937 */
1938 $$eval<Selector extends string, Params extends unknown[], Func extends EvaluateFuncWith<Array<NodeFor<Selector>>, Params> = EvaluateFuncWith<Array<NodeFor<Selector>>, Params>>(selector: Selector, pageFunction: Func | string, ...args: Params): Promise<Awaited<ReturnType<Func>>>;
1939 /**
1940 * Wait for an element matching the given selector to appear in the current
1941 * element.
1942 *
1943 * Unlike {@link Frame.waitForSelector}, this method does not work across
1944 * navigations or if the element is detached from DOM.
1945 *
1946 * @example
1947 *
1948 * ```ts
1949 * import puppeteer from 'puppeteer';
1950 *
1951 * (async () => {
1952 * const browser = await puppeteer.launch();
1953 * const page = await browser.newPage();
1954 * let currentURL;
1955 * page
1956 * .mainFrame()
1957 * .waitForSelector('img')
1958 * .then(() => console.log('First URL with image: ' + currentURL));
1959 *
1960 * for (currentURL of [
1961 * 'https://example.com',
1962 * 'https://google.com',
1963 * 'https://bbc.com',
1964 * ]) {
1965 * await page.goto(currentURL);
1966 * }
1967 * await browser.close();
1968 * })();
1969 * ```
1970 *
1971 * @param selector - The selector to query and wait for.
1972 * @param options - Options for customizing waiting behavior.
1973 * @returns An element matching the given selector.
1974 * @throws Throws if an element matching the given selector doesn't appear.
1975 */
1976 waitForSelector<Selector extends string>(selector: Selector, options?: WaitForSelectorOptions): Promise<ElementHandle<NodeFor<Selector>> | null>;
1977 /**
1978 * An element is considered to be visible if all of the following is
1979 * true:
1980 *
1981 * - the element has
1982 * {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle | computed styles}.
1983 *
1984 * - the element has a non-empty
1985 * {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect | bounding client rect}.
1986 *
1987 * - the element's {@link https://developer.mozilla.org/en-US/docs/Web/CSS/visibility | visibility}
1988 * is not `hidden` or `collapse`.
1989 */
1990 isVisible(): Promise<boolean>;
1991 /**
1992 * An element is considered to be hidden if at least one of the following is true:
1993 *
1994 * - the element has no
1995 * {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle | computed styles}.
1996 *
1997 * - the element has an empty
1998 * {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect | bounding client rect}.
1999 *
2000 * - the element's {@link https://developer.mozilla.org/en-US/docs/Web/CSS/visibility | visibility}
2001 * is `hidden` or `collapse`.
2002 */
2003 isHidden(): Promise<boolean>;
2004 /**
2005 * Converts the current handle to the given element type.
2006 *
2007 * @example
2008 *
2009 * ```ts
2010 * const element: ElementHandle<Element> = await page.$(
2011 * '.class-name-of-anchor'
2012 * );
2013 * // DO NOT DISPOSE `element`, this will be always be the same handle.
2014 * const anchor: ElementHandle<HTMLAnchorElement> =
2015 * await element.toElement('a');
2016 * ```
2017 *
2018 * @param tagName - The tag name of the desired element type.
2019 * @throws An error if the handle does not match. **The handle will not be
2020 * automatically disposed.**
2021 */
2022 toElement<K extends keyof HTMLElementTagNameMap | keyof SVGElementTagNameMap>(tagName: K): Promise<HandleFor<ElementFor<K>>>;
2023 /**
2024 * Resolves the frame associated with the element, if any. Always exists for
2025 * HTMLIFrameElements.
2026 */
2027 abstract contentFrame(this: ElementHandle<HTMLIFrameElement>): Promise<Frame>;
2028 abstract contentFrame(): Promise<Frame | null>;
2029 /**
2030 * Returns the middle point within an element unless a specific offset is provided.
2031 */
2032 clickablePoint(offset?: Offset): Promise<Point>;
2033 /**
2034 * This method scrolls element into view if needed, and then
2035 * uses {@link Page.mouse} to hover over the center of the element.
2036 * If the element is detached from DOM, the method throws an error.
2037 */
2038 hover(this: ElementHandle<Element>): Promise<void>;
2039 /**
2040 * This method scrolls element into view if needed, and then
2041 * uses {@link Page.mouse} to click in the center of the element.
2042 * If the element is detached from DOM, the method throws an error.
2043 */
2044 click(this: ElementHandle<Element>, options?: Readonly<ClickOptions>): Promise<void>;
2045 /**
2046 * Drags an element over the given element or point.
2047 *
2048 * @returns DEPRECATED. When drag interception is enabled, the drag payload is
2049 * returned.
2050 */
2051 drag(this: ElementHandle<Element>, target: Point | ElementHandle<Element>): Promise<Protocol.Input.DragData | void>;
2052 /**
2053 * @deprecated Do not use. `dragenter` will automatically be performed during dragging.
2054 */
2055 dragEnter(this: ElementHandle<Element>, data?: Protocol.Input.DragData): Promise<void>;
2056 /**
2057 * @deprecated Do not use. `dragover` will automatically be performed during dragging.
2058 */
2059 dragOver(this: ElementHandle<Element>, data?: Protocol.Input.DragData): Promise<void>;
2060 /**
2061 * Drops the given element onto the current one.
2062 */
2063 drop(this: ElementHandle<Element>, element: ElementHandle<Element>): Promise<void>;
2064 /**
2065 * @deprecated No longer supported.
2066 */
2067 drop(this: ElementHandle<Element>, data?: Protocol.Input.DragData): Promise<void>;
2068 /**
2069 * @deprecated Use `ElementHandle.drop` instead.
2070 */
2071 dragAndDrop(this: ElementHandle<Element>, target: ElementHandle<Node>, options?: {
2072 delay: number;
2073 }): Promise<void>;
2074 /**
2075 * Triggers a `change` and `input` event once all the provided options have been
2076 * selected. If there's no `<select>` element matching `selector`, the method
2077 * throws an error.
2078 *
2079 * @example
2080 *
2081 * ```ts
2082 * handle.select('blue'); // single selection
2083 * handle.select('red', 'green', 'blue'); // multiple selections
2084 * ```
2085 *
2086 * @param values - Values of options to select. If the `<select>` has the
2087 * `multiple` attribute, all values are considered, otherwise only the first
2088 * one is taken into account.
2089 */
2090 select(...values: string[]): Promise<string[]>;
2091 /**
2092 * Sets the value of an
2093 * {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input | input element}
2094 * to the given file paths.
2095 *
2096 * @remarks This will not validate whether the file paths exists. Also, if a
2097 * path is relative, then it is resolved against the
2098 * {@link https://nodejs.org/api/process.html#process_process_cwd | current working directory}.
2099 * For locals script connecting to remote chrome environments, paths must be
2100 * absolute.
2101 */
2102 abstract uploadFile(this: ElementHandle<HTMLInputElement>, ...paths: string[]): Promise<void>;
2103 /* Excluded from this release type: queryAXTree */
2104 /**
2105 * This method scrolls element into view if needed, and then uses
2106 * {@link Touchscreen.tap} to tap in the center of the element.
2107 * If the element is detached from DOM, the method throws an error.
2108 */
2109 tap(this: ElementHandle<Element>): Promise<void>;
2110 touchStart(this: ElementHandle<Element>): Promise<void>;
2111 touchMove(this: ElementHandle<Element>): Promise<void>;
2112 touchEnd(this: ElementHandle<Element>): Promise<void>;
2113 /**
2114 * Calls {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus | focus} on the element.
2115 */
2116 focus(): Promise<void>;
2117 /**
2118 * Focuses the element, and then sends a `keydown`, `keypress`/`input`, and
2119 * `keyup` event for each character in the text.
2120 *
2121 * To press a special key, like `Control` or `ArrowDown`,
2122 * use {@link ElementHandle.press}.
2123 *
2124 * @example
2125 *
2126 * ```ts
2127 * await elementHandle.type('Hello'); // Types instantly
2128 * await elementHandle.type('World', {delay: 100}); // Types slower, like a user
2129 * ```
2130 *
2131 * @example
2132 * An example of typing into a text field and then submitting the form:
2133 *
2134 * ```ts
2135 * const elementHandle = await page.$('input');
2136 * await elementHandle.type('some text');
2137 * await elementHandle.press('Enter');
2138 * ```
2139 *
2140 * @param options - Delay in milliseconds. Defaults to 0.
2141 */
2142 type(text: string, options?: Readonly<KeyboardTypeOptions>): Promise<void>;
2143 /**
2144 * Focuses the element, and then uses {@link Keyboard.down} and {@link Keyboard.up}.
2145 *
2146 * @remarks
2147 * If `key` is a single character and no modifier keys besides `Shift`
2148 * are being held down, a `keypress`/`input` event will also be generated.
2149 * The `text` option can be specified to force an input event to be generated.
2150 *
2151 * **NOTE** Modifier keys DO affect `elementHandle.press`. Holding down `Shift`
2152 * will type the text in upper case.
2153 *
2154 * @param key - Name of key to press, such as `ArrowLeft`.
2155 * See {@link KeyInput} for a list of all key names.
2156 */
2157 press(key: KeyInput, options?: Readonly<KeyPressOptions>): Promise<void>;
2158 /**
2159 * This method returns the bounding box of the element (relative to the main frame),
2160 * or `null` if the element is {@link https://drafts.csswg.org/css-display-4/#box-generation | not part of the layout}
2161 * (example: `display: none`).
2162 */
2163 boundingBox(): Promise<BoundingBox | null>;
2164 /**
2165 * This method returns boxes of the element,
2166 * or `null` if the element is {@link https://drafts.csswg.org/css-display-4/#box-generation | not part of the layout}
2167 * (example: `display: none`).
2168 *
2169 * @remarks
2170 *
2171 * Boxes are represented as an array of points;
2172 * Each Point is an object `{x, y}`. Box points are sorted clock-wise.
2173 */
2174 boxModel(): Promise<BoxModel | null>;
2175 /**
2176 * This method scrolls element into view if needed, and then uses
2177 * {@link Page.(screenshot:2) } to take a screenshot of the element.
2178 * If the element is detached from DOM, the method throws an error.
2179 */
2180 screenshot(options: Readonly<ScreenshotOptions> & {
2181 encoding: 'base64';
2182 }): Promise<string>;
2183 screenshot(options?: Readonly<ScreenshotOptions>): Promise<Uint8Array>;
2184 /* Excluded from this release type: assertConnectedElement */
2185 /* Excluded from this release type: scrollIntoViewIfNeeded */
2186 /**
2187 * Resolves to true if the element is visible in the current viewport. If an
2188 * element is an SVG, we check if the svg owner element is in the viewport
2189 * instead. See https://crbug.com/963246.
2190 *
2191 * @param options - Threshold for the intersection between 0 (no intersection) and 1
2192 * (full intersection). Defaults to 1.
2193 */
2194 isIntersectingViewport(this: ElementHandle<Element>, options?: {
2195 threshold?: number;
2196 }): Promise<boolean>;
2197 /**
2198 * Scrolls the element into view using either the automation protocol client
2199 * or by calling element.scrollIntoView.
2200 */
2201 scrollIntoView(this: ElementHandle<Element>): Promise<void>;
2202 /**
2203 * If the element is a form input, you can use {@link ElementHandle.autofill}
2204 * to test if the form is compatible with the browser's autofill
2205 * implementation. Throws an error if the form cannot be autofilled.
2206 *
2207 * @remarks
2208 *
2209 * Currently, Puppeteer supports auto-filling credit card information only and
2210 * in Chrome in the new headless and headful modes only.
2211 *
2212 * ```ts
2213 * // Select an input on the credit card form.
2214 * const name = await page.waitForSelector('form #name');
2215 * // Trigger autofill with the desired data.
2216 * await name.autofill({
2217 * creditCard: {
2218 * number: '4444444444444444',
2219 * name: 'John Smith',
2220 * expiryMonth: '01',
2221 * expiryYear: '2030',
2222 * cvc: '123',
2223 * },
2224 * });
2225 * ```
2226 */
2227 abstract autofill(data: AutofillData): Promise<void>;
2228}
2229
2230/**
2231 * @public
2232 */
2233export declare interface ElementScreenshotOptions extends ScreenshotOptions {
2234 /**
2235 * @defaultValue `true`
2236 */
2237 scrollIntoView?: boolean;
2238}
2239
2240/* Excluded from this release type: EmulatedState */
2241
2242/* Excluded from this release type: EmulationManager */
2243
2244/* Excluded from this release type: Environment */
2245
2246/**
2247 * @public
2248 */
2249export declare type ErrorCode = 'aborted' | 'accessdenied' | 'addressunreachable' | 'blockedbyclient' | 'blockedbyresponse' | 'connectionaborted' | 'connectionclosed' | 'connectionfailed' | 'connectionrefused' | 'connectionreset' | 'internetdisconnected' | 'namenotresolved' | 'timedout' | 'failed';
2250
2251/* Excluded from this release type: ErrorLike */
2252
2253/**
2254 * @public
2255 */
2256export declare type EvaluateFunc<T extends unknown[]> = (...params: InnerParams<T>) => Awaitable<unknown>;
2257
2258/**
2259 * @public
2260 */
2261export declare type EvaluateFuncWith<V, T extends unknown[]> = (...params: [V, ...InnerParams<T>]) => Awaitable<unknown>;
2262
2263/* Excluded from this release type: evaluationString */
2264
2265/**
2266 * The EventEmitter class that many Puppeteer classes extend.
2267 *
2268 * @remarks
2269 *
2270 * This allows you to listen to events that Puppeteer classes fire and act
2271 * accordingly. Therefore you'll mostly use {@link EventEmitter.on | on} and
2272 * {@link EventEmitter.off | off} to bind
2273 * and unbind to event listeners.
2274 *
2275 * @public
2276 */
2277export declare class EventEmitter<Events extends Record<EventType, unknown>> implements CommonEventEmitter<EventsWithWildcard<Events>> {
2278 #private;
2279 /* Excluded from this release type: __constructor */
2280 /**
2281 * Bind an event listener to fire when an event occurs.
2282 * @param type - the event type you'd like to listen to. Can be a string or symbol.
2283 * @param handler - the function to be called when the event occurs.
2284 * @returns `this` to enable you to chain method calls.
2285 */
2286 on<Key extends keyof EventsWithWildcard<Events>>(type: Key, handler: Handler<EventsWithWildcard<Events>[Key]>): this;
2287 /**
2288 * Remove an event listener from firing.
2289 * @param type - the event type you'd like to stop listening to.
2290 * @param handler - the function that should be removed.
2291 * @returns `this` to enable you to chain method calls.
2292 */
2293 off<Key extends keyof EventsWithWildcard<Events>>(type: Key, handler?: Handler<EventsWithWildcard<Events>[Key]>): this;
2294 /**
2295 * Emit an event and call any associated listeners.
2296 *
2297 * @param type - the event you'd like to emit
2298 * @param eventData - any data you'd like to emit with the event
2299 * @returns `true` if there are any listeners, `false` if there are not.
2300 */
2301 emit<Key extends keyof EventsWithWildcard<Events>>(type: Key, event: EventsWithWildcard<Events>[Key]): boolean;
2302 /**
2303 * Like `on` but the listener will only be fired once and then it will be removed.
2304 * @param type - the event you'd like to listen to
2305 * @param handler - the handler function to run when the event occurs
2306 * @returns `this` to enable you to chain method calls.
2307 */
2308 once<Key extends keyof EventsWithWildcard<Events>>(type: Key, handler: Handler<EventsWithWildcard<Events>[Key]>): this;
2309 /**
2310 * Gets the number of listeners for a given event.
2311 *
2312 * @param type - the event to get the listener count for
2313 * @returns the number of listeners bound to the given event
2314 */
2315 listenerCount(type: keyof EventsWithWildcard<Events>): number;
2316 /**
2317 * Removes all listeners. If given an event argument, it will remove only
2318 * listeners for that event.
2319 *
2320 * @param type - the event to remove listeners for.
2321 * @returns `this` to enable you to chain method calls.
2322 */
2323 removeAllListeners(type?: keyof EventsWithWildcard<Events>): this;
2324 /* Excluded from this release type: [disposeSymbol] */
2325}
2326
2327/**
2328 * @public
2329 */
2330export declare type EventsWithWildcard<Events extends Record<EventType, unknown>> = Events & {
2331 '*': Events[keyof Events];
2332};
2333
2334/**
2335 * @public
2336 */
2337export declare type EventType = string | symbol;
2338
2339/* Excluded from this release type: ExceptionThrownCallback */
2340
2341/**
2342 * @public
2343 */
2344export declare const
2345/**
2346* @public
2347*/
2348/**
2349 * @public
2350 */
2351executablePath: (channel?: ChromeReleaseChannel | undefined) => string;
2352
2353/* Excluded from this release type: ExecutionContext */
2354
2355/**
2356 * Defines experiment options for Puppeteer.
2357 *
2358 * See individual properties for more information.
2359 *
2360 * @public
2361 */
2362export declare type ExperimentsConfiguration = Record<string, never>;
2363
2364/**
2365 * Experimental ExtensionTransport allows establishing a connection via
2366 * chrome.debugger API if Puppeteer runs in an extension. Since Chrome
2367 * DevTools Protocol is restricted for extensions, the transport
2368 * implements missing commands and events.
2369 *
2370 * @experimental
2371 * @public
2372 */
2373export declare class ExtensionTransport implements ConnectionTransport {
2374 #private;
2375 static connectTab(tabId: number): Promise<ExtensionTransport>;
2376 onmessage?: (message: string) => void;
2377 onclose?: () => void;
2378 /* Excluded from this release type: __constructor */
2379 send(message: string): void;
2380 close(): void;
2381}
2382
2383/* Excluded from this release type: FetchRequestId */
2384
2385/**
2386 * File choosers let you react to the page requesting for a file.
2387 *
2388 * @remarks
2389 * `FileChooser` instances are returned via the {@link Page.waitForFileChooser} method.
2390 *
2391 * In browsers, only one file chooser can be opened at a time.
2392 * All file choosers must be accepted or canceled. Not doing so will prevent
2393 * subsequent file choosers from appearing.
2394 *
2395 * @example
2396 *
2397 * ```ts
2398 * const [fileChooser] = await Promise.all([
2399 * page.waitForFileChooser(),
2400 * page.click('#upload-file-button'), // some button that triggers file selection
2401 * ]);
2402 * await fileChooser.accept(['/tmp/myfile.pdf']);
2403 * ```
2404 *
2405 * @public
2406 */
2407export declare class FileChooser {
2408 #private;
2409 /* Excluded from this release type: __constructor */
2410 /**
2411 * Whether file chooser allow for
2412 * {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#attr-multiple | multiple}
2413 * file selection.
2414 */
2415 isMultiple(): boolean;
2416 /**
2417 * Accept the file chooser request with the given file paths.
2418 *
2419 * @remarks This will not validate whether the file paths exists. Also, if a
2420 * path is relative, then it is resolved against the
2421 * {@link https://nodejs.org/api/process.html#process_process_cwd | current working directory}.
2422 * For locals script connecting to remote chrome environments, paths must be
2423 * absolute.
2424 */
2425 accept(paths: string[]): Promise<void>;
2426 /**
2427 * Closes the file chooser without selecting any files.
2428 */
2429 cancel(): Promise<void>;
2430}
2431
2432/* Excluded from this release type: filterAsync */
2433
2434/* Excluded from this release type: FilteredLocator */
2435
2436/* Excluded from this release type: FirefoxLauncher */
2437
2438/**
2439 * @public
2440 */
2441export declare interface FirefoxSettings {
2442 /**
2443 * Tells Puppeteer to not download the browser during installation.
2444 *
2445 * Can be overridden by `PUPPETEER_FIREFOX_SKIP_DOWNLOAD`.
2446 *
2447 * @defaultValue true
2448 */
2449 skipDownload?: boolean;
2450 /**
2451 * Specifies the URL prefix that is used to download the browser.
2452 *
2453 * Can be overridden by `PUPPETEER_FIREFOX_DOWNLOAD_BASE_URL`.
2454 *
2455 * @remarks
2456 * This must include the protocol and may even need a path prefix.
2457 * This must **not** include a trailing slash similar to the default.
2458 *
2459 * @defaultValue https://archive.mozilla.org/pub/firefox/releases
2460 */
2461 downloadBaseUrl?: string;
2462 /**
2463 * Specifies a certain version of the browser you'd like Puppeteer to use.
2464 *
2465 * Can be overridden by `PUPPETEER_FIREFOX_VERSION`.
2466 *
2467 * See {@link PuppeteerNode.launch | puppeteer.launch} on how executable path
2468 * is inferred.
2469 *
2470 * @example stable_129.0
2471 * @defaultValue The pinned browser version supported by the current Puppeteer
2472 * version.
2473 */
2474 version?: string;
2475}
2476
2477/* Excluded from this release type: FirefoxTargetManager */
2478
2479/**
2480 * @public
2481 */
2482export declare type FlattenHandle<T> = T extends HandleOr<infer U> ? U : never;
2483
2484/* Excluded from this release type: FlattenLazyArg */
2485
2486/**
2487 * Represents a DOM frame.
2488 *
2489 * To understand frames, you can think of frames as `<iframe>` elements. Just
2490 * like iframes, frames can be nested, and when JavaScript is executed in a
2491 * frame, the JavaScript does not effect frames inside the ambient frame the
2492 * JavaScript executes in.
2493 *
2494 * @example
2495 * At any point in time, {@link Page | pages} expose their current frame
2496 * tree via the {@link Page.mainFrame} and {@link Frame.childFrames} methods.
2497 *
2498 * @example
2499 * An example of dumping frame tree:
2500 *
2501 * ```ts
2502 * import puppeteer from 'puppeteer';
2503 *
2504 * (async () => {
2505 * const browser = await puppeteer.launch();
2506 * const page = await browser.newPage();
2507 * await page.goto('https://www.google.com/chrome/browser/canary.html');
2508 * dumpFrameTree(page.mainFrame(), '');
2509 * await browser.close();
2510 *
2511 * function dumpFrameTree(frame, indent) {
2512 * console.log(indent + frame.url());
2513 * for (const child of frame.childFrames()) {
2514 * dumpFrameTree(child, indent + ' ');
2515 * }
2516 * }
2517 * })();
2518 * ```
2519 *
2520 * @example
2521 * An example of getting text from an iframe element:
2522 *
2523 * ```ts
2524 * const frame = page.frames().find(frame => frame.name() === 'myframe');
2525 * const text = await frame.$eval('.selector', element => element.textContent);
2526 * console.log(text);
2527 * ```
2528 *
2529 * @remarks
2530 * Frame lifecycles are controlled by three events that are all dispatched on
2531 * the parent {@link Frame.page | page}:
2532 *
2533 * - {@link PageEvent.FrameAttached}
2534 * - {@link PageEvent.FrameNavigated}
2535 * - {@link PageEvent.FrameDetached}
2536 *
2537 * @public
2538 */
2539export declare abstract class Frame extends EventEmitter<FrameEvents> {
2540 #private;
2541 /* Excluded from this release type: _id */
2542 /* Excluded from this release type: _parentId */
2543 /* Excluded from this release type: _name */
2544 /* Excluded from this release type: _hasStartedLoading */
2545 /* Excluded from this release type: __constructor */
2546 /**
2547 * The page associated with the frame.
2548 */
2549 abstract page(): Page;
2550 /**
2551 * Navigates the frame or page to the given `url`.
2552 *
2553 * @remarks
2554 * Navigation to `about:blank` or navigation to the same URL with a different
2555 * hash will succeed and return `null`.
2556 *
2557 * :::warning
2558 *
2559 * Headless shell mode doesn't support navigation to a PDF document. See the
2560 * {@link https://crbug.com/761295 | upstream issue}.
2561 *
2562 * :::
2563 *
2564 * In headless shell, this method will not throw an error when any valid HTTP
2565 * status code is returned by the remote server, including 404 "Not Found" and
2566 * 500 "Internal Server Error". The status code for such responses can be
2567 * retrieved by calling {@link HTTPResponse.status}.
2568 *
2569 * @param url - URL to navigate the frame to. The URL should include scheme,
2570 * e.g. `https://`
2571 * @param options - Options to configure waiting behavior.
2572 * @returns A promise which resolves to the main resource response. In case of
2573 * multiple redirects, the navigation will resolve with the response of the
2574 * last redirect.
2575 * @throws If:
2576 *
2577 * - there's an SSL error (e.g. in case of self-signed certificates).
2578 *
2579 * - target URL is invalid.
2580 *
2581 * - the timeout is exceeded during navigation.
2582 *
2583 * - the remote server does not respond or is unreachable.
2584 *
2585 * - the main resource failed to load.
2586 */
2587 abstract goto(url: string, options?: GoToOptions): Promise<HTTPResponse | null>;
2588 /**
2589 * Waits for the frame to navigate. It is useful for when you run code which
2590 * will indirectly cause the frame to navigate.
2591 *
2592 * Usage of the
2593 * {@link https://developer.mozilla.org/en-US/docs/Web/API/History_API | History API}
2594 * to change the URL is considered a navigation.
2595 *
2596 * @example
2597 *
2598 * ```ts
2599 * const [response] = await Promise.all([
2600 * // The navigation promise resolves after navigation has finished
2601 * frame.waitForNavigation(),
2602 * // Clicking the link will indirectly cause a navigation
2603 * frame.click('a.my-link'),
2604 * ]);
2605 * ```
2606 *
2607 * @param options - Options to configure waiting behavior.
2608 * @returns A promise which resolves to the main resource response.
2609 */
2610 abstract waitForNavigation(options?: WaitForOptions): Promise<HTTPResponse | null>;
2611 /* Excluded from this release type: client */
2612 /* Excluded from this release type: accessibility */
2613 /* Excluded from this release type: mainRealm */
2614 /* Excluded from this release type: isolatedRealm */
2615 /* Excluded from this release type: clearDocumentHandle */
2616 /**
2617 * @returns The frame element associated with this frame (if any).
2618 */
2619 frameElement(): Promise<HandleFor<HTMLIFrameElement> | null>;
2620 /**
2621 * Behaves identically to {@link Page.evaluateHandle} except it's run within
2622 * the context of this frame.
2623 *
2624 * See {@link Page.evaluateHandle} for details.
2625 */
2626 evaluateHandle<Params extends unknown[], Func extends EvaluateFunc<Params> = EvaluateFunc<Params>>(pageFunction: Func | string, ...args: Params): Promise<HandleFor<Awaited<ReturnType<Func>>>>;
2627 /**
2628 * Behaves identically to {@link Page.evaluate} except it's run within
2629 * the context of this frame.
2630 *
2631 * See {@link Page.evaluate} for details.
2632 */
2633 evaluate<Params extends unknown[], Func extends EvaluateFunc<Params> = EvaluateFunc<Params>>(pageFunction: Func | string, ...args: Params): Promise<Awaited<ReturnType<Func>>>;
2634 /**
2635 * Creates a locator for the provided selector. See {@link Locator} for
2636 * details and supported actions.
2637 *
2638 * @param selector -
2639 * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
2640 * to query the page for.
2641 * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
2642 * can be passed as-is and a
2643 * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
2644 * allows quering by
2645 * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
2646 * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
2647 * and
2648 * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
2649 * and
2650 * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
2651 * Alternatively, you can specify the selector type using a
2652 * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
2653 */
2654 locator<Selector extends string>(selector: Selector): Locator<NodeFor<Selector>>;
2655 /**
2656 * Creates a locator for the provided function. See {@link Locator} for
2657 * details and supported actions.
2658 */
2659 locator<Ret>(func: () => Awaitable<Ret>): Locator<Ret>;
2660 /**
2661 * Queries the frame for an element matching the given selector.
2662 *
2663 * @param selector -
2664 * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
2665 * to query the page for.
2666 * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
2667 * can be passed as-is and a
2668 * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
2669 * allows quering by
2670 * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
2671 * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
2672 * and
2673 * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
2674 * and
2675 * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
2676 * Alternatively, you can specify the selector type using a
2677 * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
2678 *
2679 * @returns A {@link ElementHandle | element handle} to the first element
2680 * matching the given selector. Otherwise, `null`.
2681 */
2682 $<Selector extends string>(selector: Selector): Promise<ElementHandle<NodeFor<Selector>> | null>;
2683 /**
2684 * Queries the frame for all elements matching the given selector.
2685 *
2686 * @param selector -
2687 * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
2688 * to query the page for.
2689 * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
2690 * can be passed as-is and a
2691 * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
2692 * allows quering by
2693 * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
2694 * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
2695 * and
2696 * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
2697 * and
2698 * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
2699 * Alternatively, you can specify the selector type using a
2700 * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
2701 *
2702 * @returns An array of {@link ElementHandle | element handles} that point to
2703 * elements matching the given selector.
2704 */
2705 $$<Selector extends string>(selector: Selector, options?: QueryOptions): Promise<Array<ElementHandle<NodeFor<Selector>>>>;
2706 /**
2707 * Runs the given function on the first element matching the given selector in
2708 * the frame.
2709 *
2710 * If the given function returns a promise, then this method will wait till
2711 * the promise resolves.
2712 *
2713 * @example
2714 *
2715 * ```ts
2716 * const searchValue = await frame.$eval('#search', el => el.value);
2717 * ```
2718 *
2719 * @param selector -
2720 * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
2721 * to query the page for.
2722 * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
2723 * can be passed as-is and a
2724 * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
2725 * allows quering by
2726 * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
2727 * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
2728 * and
2729 * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
2730 * and
2731 * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
2732 * Alternatively, you can specify the selector type using a
2733 * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
2734 * @param pageFunction - The function to be evaluated in the frame's context.
2735 * The first element matching the selector will be passed to the function as
2736 * its first argument.
2737 * @param args - Additional arguments to pass to `pageFunction`.
2738 * @returns A promise to the result of the function.
2739 */
2740 $eval<Selector extends string, Params extends unknown[], Func extends EvaluateFuncWith<NodeFor<Selector>, Params> = EvaluateFuncWith<NodeFor<Selector>, Params>>(selector: Selector, pageFunction: string | Func, ...args: Params): Promise<Awaited<ReturnType<Func>>>;
2741 /**
2742 * Runs the given function on an array of elements matching the given selector
2743 * in the frame.
2744 *
2745 * If the given function returns a promise, then this method will wait till
2746 * the promise resolves.
2747 *
2748 * @example
2749 *
2750 * ```ts
2751 * const divsCounts = await frame.$$eval('div', divs => divs.length);
2752 * ```
2753 *
2754 * @param selector -
2755 * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
2756 * to query the page for.
2757 * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
2758 * can be passed as-is and a
2759 * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
2760 * allows quering by
2761 * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
2762 * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
2763 * and
2764 * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
2765 * and
2766 * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
2767 * Alternatively, you can specify the selector type using a
2768 * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
2769 * @param pageFunction - The function to be evaluated in the frame's context.
2770 * An array of elements matching the given selector will be passed to the
2771 * function as its first argument.
2772 * @param args - Additional arguments to pass to `pageFunction`.
2773 * @returns A promise to the result of the function.
2774 */
2775 $$eval<Selector extends string, Params extends unknown[], Func extends EvaluateFuncWith<Array<NodeFor<Selector>>, Params> = EvaluateFuncWith<Array<NodeFor<Selector>>, Params>>(selector: Selector, pageFunction: string | Func, ...args: Params): Promise<Awaited<ReturnType<Func>>>;
2776 /**
2777 * Waits for an element matching the given selector to appear in the frame.
2778 *
2779 * This method works across navigations.
2780 *
2781 * @example
2782 *
2783 * ```ts
2784 * import puppeteer from 'puppeteer';
2785 *
2786 * (async () => {
2787 * const browser = await puppeteer.launch();
2788 * const page = await browser.newPage();
2789 * let currentURL;
2790 * page
2791 * .mainFrame()
2792 * .waitForSelector('img')
2793 * .then(() => console.log('First URL with image: ' + currentURL));
2794 *
2795 * for (currentURL of [
2796 * 'https://example.com',
2797 * 'https://google.com',
2798 * 'https://bbc.com',
2799 * ]) {
2800 * await page.goto(currentURL);
2801 * }
2802 * await browser.close();
2803 * })();
2804 * ```
2805 *
2806 * @param selector - The selector to query and wait for.
2807 * @param options - Options for customizing waiting behavior.
2808 * @returns An element matching the given selector.
2809 * @throws Throws if an element matching the given selector doesn't appear.
2810 */
2811 waitForSelector<Selector extends string>(selector: Selector, options?: WaitForSelectorOptions): Promise<ElementHandle<NodeFor<Selector>> | null>;
2812 /**
2813 * @example
2814 * The `waitForFunction` can be used to observe viewport size change:
2815 *
2816 * ```ts
2817 * import puppeteer from 'puppeteer';
2818 *
2819 * (async () => {
2820 * . const browser = await puppeteer.launch();
2821 * . const page = await browser.newPage();
2822 * . const watchDog = page.mainFrame().waitForFunction('window.innerWidth < 100');
2823 * . page.setViewport({width: 50, height: 50});
2824 * . await watchDog;
2825 * . await browser.close();
2826 * })();
2827 * ```
2828 *
2829 * To pass arguments from Node.js to the predicate of `page.waitForFunction` function:
2830 *
2831 * ```ts
2832 * const selector = '.foo';
2833 * await frame.waitForFunction(
2834 * selector => !!document.querySelector(selector),
2835 * {}, // empty options object
2836 * selector
2837 * );
2838 * ```
2839 *
2840 * @param pageFunction - the function to evaluate in the frame context.
2841 * @param options - options to configure the polling method and timeout.
2842 * @param args - arguments to pass to the `pageFunction`.
2843 * @returns the promise which resolve when the `pageFunction` returns a truthy value.
2844 */
2845 waitForFunction<Params extends unknown[], Func extends EvaluateFunc<Params> = EvaluateFunc<Params>>(pageFunction: Func | string, options?: FrameWaitForFunctionOptions, ...args: Params): Promise<HandleFor<Awaited<ReturnType<Func>>>>;
2846 /**
2847 * The full HTML contents of the frame, including the DOCTYPE.
2848 */
2849 content(): Promise<string>;
2850 /**
2851 * Set the content of the frame.
2852 *
2853 * @param html - HTML markup to assign to the page.
2854 * @param options - Options to configure how long before timing out and at
2855 * what point to consider the content setting successful.
2856 */
2857 abstract setContent(html: string, options?: WaitForOptions): Promise<void>;
2858 /* Excluded from this release type: setFrameContent */
2859 /**
2860 * The frame's `name` attribute as specified in the tag.
2861 *
2862 * @remarks
2863 * If the name is empty, it returns the `id` attribute instead.
2864 *
2865 * @remarks
2866 * This value is calculated once when the frame is created, and will not
2867 * update if the attribute is changed later.
2868 *
2869 * @deprecated Use
2870 *
2871 * ```ts
2872 * const element = await frame.frameElement();
2873 * const nameOrId = await element.evaluate(frame => frame.name ?? frame.id);
2874 * ```
2875 */
2876 name(): string;
2877 /**
2878 * The frame's URL.
2879 */
2880 abstract url(): string;
2881 /**
2882 * The parent frame, if any. Detached and main frames return `null`.
2883 */
2884 abstract parentFrame(): Frame | null;
2885 /**
2886 * An array of child frames.
2887 */
2888 abstract childFrames(): Frame[];
2889 /**
2890 * @returns `true` if the frame has detached. `false` otherwise.
2891 */
2892 abstract get detached(): boolean;
2893 /**
2894 * Is`true` if the frame has been detached. Otherwise, `false`.
2895 *
2896 * @deprecated Use the `detached` getter.
2897 */
2898 isDetached(): boolean;
2899 /* Excluded from this release type: disposed */
2900 /**
2901 * Adds a `<script>` tag into the page with the desired url or content.
2902 *
2903 * @param options - Options for the script.
2904 * @returns An {@link ElementHandle | element handle} to the injected
2905 * `<script>` element.
2906 */
2907 addScriptTag(options: FrameAddScriptTagOptions): Promise<ElementHandle<HTMLScriptElement>>;
2908 /**
2909 * Adds a `HTMLStyleElement` into the frame with the desired URL
2910 *
2911 * @returns An {@link ElementHandle | element handle} to the loaded `<style>`
2912 * element.
2913 */
2914 addStyleTag(options: Omit<FrameAddStyleTagOptions, 'url'>): Promise<ElementHandle<HTMLStyleElement>>;
2915 /**
2916 * Adds a `HTMLLinkElement` into the frame with the desired URL
2917 *
2918 * @returns An {@link ElementHandle | element handle} to the loaded `<link>`
2919 * element.
2920 */
2921 addStyleTag(options: FrameAddStyleTagOptions): Promise<ElementHandle<HTMLLinkElement>>;
2922 /**
2923 * Clicks the first element found that matches `selector`.
2924 *
2925 * @remarks
2926 * If `click()` triggers a navigation event and there's a separate
2927 * `page.waitForNavigation()` promise to be resolved, you may end up with a
2928 * race condition that yields unexpected results. The correct pattern for
2929 * click and wait for navigation is the following:
2930 *
2931 * ```ts
2932 * const [response] = await Promise.all([
2933 * page.waitForNavigation(waitOptions),
2934 * frame.click(selector, clickOptions),
2935 * ]);
2936 * ```
2937 *
2938 * @param selector - The selector to query for.
2939 */
2940 click(selector: string, options?: Readonly<ClickOptions>): Promise<void>;
2941 /**
2942 * Focuses the first element that matches the `selector`.
2943 *
2944 * @param selector - The selector to query for.
2945 * @throws Throws if there's no element matching `selector`.
2946 */
2947 focus(selector: string): Promise<void>;
2948 /**
2949 * Hovers the pointer over the center of the first element that matches the
2950 * `selector`.
2951 *
2952 * @param selector - The selector to query for.
2953 * @throws Throws if there's no element matching `selector`.
2954 */
2955 hover(selector: string): Promise<void>;
2956 /**
2957 * Selects a set of value on the first `<select>` element that matches the
2958 * `selector`.
2959 *
2960 * @example
2961 *
2962 * ```ts
2963 * frame.select('select#colors', 'blue'); // single selection
2964 * frame.select('select#colors', 'red', 'green', 'blue'); // multiple selections
2965 * ```
2966 *
2967 * @param selector - The selector to query for.
2968 * @param values - The array of values to select. If the `<select>` has the
2969 * `multiple` attribute, all values are considered, otherwise only the first
2970 * one is taken into account.
2971 * @returns the list of values that were successfully selected.
2972 * @throws Throws if there's no `<select>` matching `selector`.
2973 */
2974 select(selector: string, ...values: string[]): Promise<string[]>;
2975 /**
2976 * Taps the first element that matches the `selector`.
2977 *
2978 * @param selector - The selector to query for.
2979 * @throws Throws if there's no element matching `selector`.
2980 */
2981 tap(selector: string): Promise<void>;
2982 /**
2983 * Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character
2984 * in the text.
2985 *
2986 * @remarks
2987 * To press a special key, like `Control` or `ArrowDown`, use
2988 * {@link Keyboard.press}.
2989 *
2990 * @example
2991 *
2992 * ```ts
2993 * await frame.type('#mytextarea', 'Hello'); // Types instantly
2994 * await frame.type('#mytextarea', 'World', {delay: 100}); // Types slower, like a user
2995 * ```
2996 *
2997 * @param selector - the selector for the element to type into. If there are
2998 * multiple the first will be used.
2999 * @param text - text to type into the element
3000 * @param options - takes one option, `delay`, which sets the time to wait
3001 * between key presses in milliseconds. Defaults to `0`.
3002 */
3003 type(selector: string, text: string, options?: Readonly<KeyboardTypeOptions>): Promise<void>;
3004 /**
3005 * The frame's title.
3006 */
3007 title(): Promise<string>;
3008 /* Excluded from this release type: waitForDevicePrompt */
3009}
3010
3011/**
3012 * @public
3013 */
3014export declare interface FrameAddScriptTagOptions {
3015 /**
3016 * URL of the script to be added.
3017 */
3018 url?: string;
3019 /**
3020 * Path to a JavaScript file to be injected into the frame.
3021 *
3022 * @remarks
3023 * If `path` is a relative path, it is resolved relative to the current
3024 * working directory (`process.cwd()` in Node.js).
3025 */
3026 path?: string;
3027 /**
3028 * JavaScript to be injected into the frame.
3029 */
3030 content?: string;
3031 /**
3032 * Sets the `type` of the script. Use `module` in order to load an ES2015 module.
3033 */
3034 type?: string;
3035 /**
3036 * Sets the `id` of the script.
3037 */
3038 id?: string;
3039}
3040
3041/**
3042 * @public
3043 */
3044export declare interface FrameAddStyleTagOptions {
3045 /**
3046 * the URL of the CSS file to be added.
3047 */
3048 url?: string;
3049 /**
3050 * The path to a CSS file to be injected into the frame.
3051 * @remarks
3052 * If `path` is a relative path, it is resolved relative to the current
3053 * working directory (`process.cwd()` in Node.js).
3054 */
3055 path?: string;
3056 /**
3057 * Raw CSS content to be injected into the frame.
3058 */
3059 content?: string;
3060}
3061
3062/* Excluded from this release type: FrameEvent */
3063
3064/**
3065 * @public
3066 */
3067export declare interface FrameEvents extends Record<EventType, unknown> {
3068 /* Excluded from this release type: [FrameEvent.FrameNavigated] */
3069 /* Excluded from this release type: [FrameEvent.FrameSwapped] */
3070 /* Excluded from this release type: [FrameEvent.LifecycleEvent] */
3071 /* Excluded from this release type: [FrameEvent.FrameNavigatedWithinDocument] */
3072 /* Excluded from this release type: [FrameEvent.FrameDetached] */
3073 /* Excluded from this release type: [FrameEvent.FrameSwappedByActivation] */
3074}
3075
3076/* Excluded from this release type: FrameManager */
3077
3078/* Excluded from this release type: FrameManagerEvent */
3079
3080/* Excluded from this release type: FrameManagerEvents */
3081
3082/* Excluded from this release type: FrameProvider */
3083
3084/* Excluded from this release type: FrameTree */
3085
3086/**
3087 * @public
3088 */
3089export declare interface FrameWaitForFunctionOptions {
3090 /**
3091 * An interval at which the `pageFunction` is executed, defaults to `raf`. If
3092 * `polling` is a number, then it is treated as an interval in milliseconds at
3093 * which the function would be executed. If `polling` is a string, then it can
3094 * be one of the following values:
3095 *
3096 * - `raf` - to constantly execute `pageFunction` in `requestAnimationFrame`
3097 * callback. This is the tightest polling mode which is suitable to observe
3098 * styling changes.
3099 *
3100 * - `mutation` - to execute `pageFunction` on every DOM mutation.
3101 */
3102 polling?: 'raf' | 'mutation' | number;
3103 /**
3104 * Maximum time to wait in milliseconds. Defaults to `30000` (30 seconds).
3105 * Pass `0` to disable the timeout. Puppeteer's default timeout can be changed
3106 * using {@link Page.setDefaultTimeout}.
3107 */
3108 timeout?: number;
3109 /**
3110 * A signal object that allows you to cancel a waitForFunction call.
3111 */
3112 signal?: AbortSignal;
3113}
3114
3115/* Excluded from this release type: fromAbortSignal */
3116
3117/* Excluded from this release type: fromEmitterEvent */
3118
3119/* Excluded from this release type: FunctionLocator */
3120
3121/**
3122 * @public
3123 */
3124export declare interface GeolocationOptions {
3125 /**
3126 * Latitude between `-90` and `90`.
3127 */
3128 longitude: number;
3129 /**
3130 * Longitude between `-180` and `180`.
3131 */
3132 latitude: number;
3133 /**
3134 * Optional non-negative accuracy value.
3135 */
3136 accuracy?: number;
3137}
3138
3139/* Excluded from this release type: getCapturedLogs */
3140
3141/* Excluded from this release type: getFeatures */
3142
3143/* Excluded from this release type: GetIdFn */
3144
3145/* Excluded from this release type: getQueryHandlerAndSelector */
3146
3147/* Excluded from this release type: getReadableAsTypedArray */
3148
3149/* Excluded from this release type: getReadableFromProtocolStream */
3150
3151/* Excluded from this release type: getSourcePuppeteerURLIfAvailable */
3152
3153/* Excluded from this release type: getSourceUrlComment */
3154
3155/**
3156 * @public
3157 */
3158export declare interface GoToOptions extends WaitForOptions {
3159 /**
3160 * If provided, it will take preference over the referer header value set by
3161 * {@link Page.setExtraHTTPHeaders | page.setExtraHTTPHeaders()}.
3162 */
3163 referer?: string;
3164 /**
3165 * If provided, it will take preference over the referer-policy header value
3166 * set by {@link Page.setExtraHTTPHeaders | page.setExtraHTTPHeaders()}.
3167 */
3168 referrerPolicy?: string;
3169}
3170
3171/* Excluded from this release type: handleError */
3172
3173/**
3174 * @public
3175 */
3176export declare type HandleFor<T> = T extends Node ? ElementHandle<T> : JSHandle<T>;
3177
3178/* Excluded from this release type: HandleMapper */
3179
3180/**
3181 * @public
3182 */
3183export declare type HandleOr<T> = HandleFor<T> | JSHandle<T> | T;
3184
3185/* Excluded from this release type: HandlePredicate */
3186
3187/**
3188 * @public
3189 */
3190export declare type Handler<T = unknown> = (event: T) => void;
3191
3192/* Excluded from this release type: headersArray */
3193
3194/**
3195 * Represents an HTTP request sent by a page.
3196 * @remarks
3197 *
3198 * Whenever the page sends a request, such as for a network resource, the
3199 * following events are emitted by Puppeteer's `page`:
3200 *
3201 * - `request`: emitted when the request is issued by the page.
3202 * - `requestfinished` - emitted when the response body is downloaded and the
3203 * request is complete.
3204 *
3205 * If request fails at some point, then instead of `requestfinished` event the
3206 * `requestfailed` event is emitted.
3207 *
3208 * All of these events provide an instance of `HTTPRequest` representing the
3209 * request that occurred:
3210 *
3211 * ```
3212 * page.on('request', request => ...)
3213 * ```
3214 *
3215 * NOTE: HTTP Error responses, such as 404 or 503, are still successful
3216 * responses from HTTP standpoint, so request will complete with
3217 * `requestfinished` event.
3218 *
3219 * If request gets a 'redirect' response, the request is successfully finished
3220 * with the `requestfinished` event, and a new request is issued to a
3221 * redirected url.
3222 *
3223 * @public
3224 */
3225export declare abstract class HTTPRequest {
3226 #private;
3227 /* Excluded from this release type: id */
3228 /* Excluded from this release type: _interceptionId */
3229 /* Excluded from this release type: _failureText */
3230 /* Excluded from this release type: _response */
3231 /* Excluded from this release type: _fromMemoryCache */
3232 /* Excluded from this release type: _redirectChain */
3233 /* Excluded from this release type: interception */
3234 /**
3235 * Warning! Using this client can break Puppeteer. Use with caution.
3236 *
3237 * @experimental
3238 */
3239 abstract get client(): CDPSession;
3240 /* Excluded from this release type: __constructor */
3241 /**
3242 * The URL of the request
3243 */
3244 abstract url(): string;
3245 /**
3246 * The `ContinueRequestOverrides` that will be used
3247 * if the interception is allowed to continue (ie, `abort()` and
3248 * `respond()` aren't called).
3249 */
3250 continueRequestOverrides(): ContinueRequestOverrides;
3251 /**
3252 * The `ResponseForRequest` that gets used if the
3253 * interception is allowed to respond (ie, `abort()` is not called).
3254 */
3255 responseForRequest(): Partial<ResponseForRequest> | null;
3256 /**
3257 * The most recent reason for aborting the request
3258 */
3259 abortErrorReason(): Protocol.Network.ErrorReason | null;
3260 /**
3261 * An InterceptResolutionState object describing the current resolution
3262 * action and priority.
3263 *
3264 * InterceptResolutionState contains:
3265 * action: InterceptResolutionAction
3266 * priority?: number
3267 *
3268 * InterceptResolutionAction is one of: `abort`, `respond`, `continue`,
3269 * `disabled`, `none`, or `already-handled`.
3270 */
3271 interceptResolutionState(): InterceptResolutionState;
3272 /**
3273 * Is `true` if the intercept resolution has already been handled,
3274 * `false` otherwise.
3275 */
3276 isInterceptResolutionHandled(): boolean;
3277 /**
3278 * Adds an async request handler to the processing queue.
3279 * Deferred handlers are not guaranteed to execute in any particular order,
3280 * but they are guaranteed to resolve before the request interception
3281 * is finalized.
3282 */
3283 enqueueInterceptAction(pendingHandler: () => void | PromiseLike<unknown>): void;
3284 /* Excluded from this release type: _abort */
3285 /* Excluded from this release type: _respond */
3286 /* Excluded from this release type: _continue */
3287 /**
3288 * Awaits pending interception handlers and then decides how to fulfill
3289 * the request interception.
3290 */
3291 finalizeInterceptions(): Promise<void>;
3292 /**
3293 * Contains the request's resource type as it was perceived by the rendering
3294 * engine.
3295 */
3296 abstract resourceType(): ResourceType;
3297 /**
3298 * The method used (`GET`, `POST`, etc.)
3299 */
3300 abstract method(): string;
3301 /**
3302 * The request's post body, if any.
3303 */
3304 abstract postData(): string | undefined;
3305 /**
3306 * True when the request has POST data. Note that {@link HTTPRequest.postData}
3307 * might still be undefined when this flag is true when the data is too long
3308 * or not readily available in the decoded form. In that case, use
3309 * {@link HTTPRequest.fetchPostData}.
3310 */
3311 abstract hasPostData(): boolean;
3312 /**
3313 * Fetches the POST data for the request from the browser.
3314 */
3315 abstract fetchPostData(): Promise<string | undefined>;
3316 /**
3317 * An object with HTTP headers associated with the request. All
3318 * header names are lower-case.
3319 */
3320 abstract headers(): Record<string, string>;
3321 /**
3322 * A matching `HTTPResponse` object, or null if the response has not
3323 * been received yet.
3324 */
3325 abstract response(): HTTPResponse | null;
3326 /**
3327 * The frame that initiated the request, or null if navigating to
3328 * error pages.
3329 */
3330 abstract frame(): Frame | null;
3331 /**
3332 * True if the request is the driver of the current frame's navigation.
3333 */
3334 abstract isNavigationRequest(): boolean;
3335 /**
3336 * The initiator of the request.
3337 */
3338 abstract initiator(): Protocol.Network.Initiator | undefined;
3339 /**
3340 * A `redirectChain` is a chain of requests initiated to fetch a resource.
3341 * @remarks
3342 *
3343 * `redirectChain` is shared between all the requests of the same chain.
3344 *
3345 * For example, if the website `http://example.com` has a single redirect to
3346 * `https://example.com`, then the chain will contain one request:
3347 *
3348 * ```ts
3349 * const response = await page.goto('http://example.com');
3350 * const chain = response.request().redirectChain();
3351 * console.log(chain.length); // 1
3352 * console.log(chain[0].url()); // 'http://example.com'
3353 * ```
3354 *
3355 * If the website `https://google.com` has no redirects, then the chain will be empty:
3356 *
3357 * ```ts
3358 * const response = await page.goto('https://google.com');
3359 * const chain = response.request().redirectChain();
3360 * console.log(chain.length); // 0
3361 * ```
3362 *
3363 * @returns the chain of requests - if a server responds with at least a
3364 * single redirect, this chain will contain all requests that were redirected.
3365 */
3366 abstract redirectChain(): HTTPRequest[];
3367 /**
3368 * Access information about the request's failure.
3369 *
3370 * @remarks
3371 *
3372 * @example
3373 *
3374 * Example of logging all failed requests:
3375 *
3376 * ```ts
3377 * page.on('requestfailed', request => {
3378 * console.log(request.url() + ' ' + request.failure().errorText);
3379 * });
3380 * ```
3381 *
3382 * @returns `null` unless the request failed. If the request fails this can
3383 * return an object with `errorText` containing a human-readable error
3384 * message, e.g. `net::ERR_FAILED`. It is not guaranteed that there will be
3385 * failure text if the request fails.
3386 */
3387 abstract failure(): {
3388 errorText: string;
3389 } | null;
3390 /**
3391 * Continues request with optional request overrides.
3392 *
3393 * @example
3394 *
3395 * ```ts
3396 * await page.setRequestInterception(true);
3397 * page.on('request', request => {
3398 * // Override headers
3399 * const headers = Object.assign({}, request.headers(), {
3400 * foo: 'bar', // set "foo" header
3401 * origin: undefined, // remove "origin" header
3402 * });
3403 * request.continue({headers});
3404 * });
3405 * ```
3406 *
3407 * @param overrides - optional overrides to apply to the request.
3408 * @param priority - If provided, intercept is resolved using cooperative
3409 * handling rules. Otherwise, intercept is resolved immediately.
3410 *
3411 * @remarks
3412 *
3413 * To use this, request interception should be enabled with
3414 * {@link Page.setRequestInterception}.
3415 *
3416 * Exception is immediately thrown if the request interception is not enabled.
3417 */
3418 continue(overrides?: ContinueRequestOverrides, priority?: number): Promise<void>;
3419 /**
3420 * Fulfills a request with the given response.
3421 *
3422 * @example
3423 * An example of fulfilling all requests with 404 responses:
3424 *
3425 * ```ts
3426 * await page.setRequestInterception(true);
3427 * page.on('request', request => {
3428 * request.respond({
3429 * status: 404,
3430 * contentType: 'text/plain',
3431 * body: 'Not Found!',
3432 * });
3433 * });
3434 * ```
3435 *
3436 * NOTE: Mocking responses for dataURL requests is not supported.
3437 * Calling `request.respond` for a dataURL request is a noop.
3438 *
3439 * @param response - the response to fulfill the request with.
3440 * @param priority - If provided, intercept is resolved using
3441 * cooperative handling rules. Otherwise, intercept is resolved
3442 * immediately.
3443 *
3444 * @remarks
3445 *
3446 * To use this, request
3447 * interception should be enabled with {@link Page.setRequestInterception}.
3448 *
3449 * Exception is immediately thrown if the request interception is not enabled.
3450 */
3451 respond(response: Partial<ResponseForRequest>, priority?: number): Promise<void>;
3452 /**
3453 * Aborts a request.
3454 *
3455 * @param errorCode - optional error code to provide.
3456 * @param priority - If provided, intercept is resolved using
3457 * cooperative handling rules. Otherwise, intercept is resolved
3458 * immediately.
3459 *
3460 * @remarks
3461 *
3462 * To use this, request interception should be enabled with
3463 * {@link Page.setRequestInterception}. If it is not enabled, this method will
3464 * throw an exception immediately.
3465 */
3466 abort(errorCode?: ErrorCode, priority?: number): Promise<void>;
3467 /* Excluded from this release type: getResponse */
3468}
3469
3470/**
3471 * The HTTPResponse class represents responses which are received by the
3472 * {@link Page} class.
3473 *
3474 * @public
3475 */
3476export declare abstract class HTTPResponse {
3477 /* Excluded from this release type: __constructor */
3478 /**
3479 * The IP address and port number used to connect to the remote
3480 * server.
3481 */
3482 abstract remoteAddress(): RemoteAddress;
3483 /**
3484 * The URL of the response.
3485 */
3486 abstract url(): string;
3487 /**
3488 * True if the response was successful (status in the range 200-299).
3489 */
3490 ok(): boolean;
3491 /**
3492 * The status code of the response (e.g., 200 for a success).
3493 */
3494 abstract status(): number;
3495 /**
3496 * The status text of the response (e.g. usually an "OK" for a
3497 * success).
3498 */
3499 abstract statusText(): string;
3500 /**
3501 * An object with HTTP headers associated with the response. All
3502 * header names are lower-case.
3503 */
3504 abstract headers(): Record<string, string>;
3505 /**
3506 * {@link SecurityDetails} if the response was received over the
3507 * secure connection, or `null` otherwise.
3508 */
3509 abstract securityDetails(): SecurityDetails | null;
3510 /**
3511 * Timing information related to the response.
3512 */
3513 abstract timing(): Protocol.Network.ResourceTiming | null;
3514 /**
3515 * Promise which resolves to a buffer with response body.
3516 *
3517 * @remarks
3518 *
3519 * The buffer might be re-encoded by the browser
3520 * based on HTTP-headers or other heuristics. If the browser
3521 * failed to detect the correct encoding, the buffer might
3522 * be encoded incorrectly. See https://github.com/puppeteer/puppeteer/issues/6478.
3523 */
3524 abstract content(): Promise<Uint8Array>;
3525 /**
3526 * {@inheritDoc HTTPResponse.content}
3527 */
3528 buffer(): Promise<Buffer>;
3529 /**
3530 * Promise which resolves to a text (utf8) representation of response body.
3531 */
3532 text(): Promise<string>;
3533 /**
3534 * Promise which resolves to a JSON representation of response body.
3535 *
3536 * @remarks
3537 *
3538 * This method will throw if the response body is not parsable via
3539 * `JSON.parse`.
3540 */
3541 json(): Promise<any>;
3542 /**
3543 * A matching {@link HTTPRequest} object.
3544 */
3545 abstract request(): HTTPRequest;
3546 /**
3547 * True if the response was served from either the browser's disk
3548 * cache or memory cache.
3549 */
3550 abstract fromCache(): boolean;
3551 /**
3552 * True if the response was served by a service worker.
3553 */
3554 abstract fromServiceWorker(): boolean;
3555 /**
3556 * A {@link Frame} that initiated this response, or `null` if
3557 * navigating to error pages.
3558 */
3559 abstract frame(): Frame | null;
3560}
3561
3562/* Excluded from this release type: importDebug */
3563
3564/* Excluded from this release type: InitializationStatus */
3565
3566/* Excluded from this release type: InnerLazyParams */
3567
3568/**
3569 * @public
3570 */
3571export declare type InnerParams<T extends unknown[]> = {
3572 [K in keyof T]: FlattenHandle<T[K]>;
3573};
3574
3575/**
3576 * @public
3577 */
3578export declare enum InterceptResolutionAction {
3579 Abort = "abort",
3580 Respond = "respond",
3581 Continue = "continue",
3582 Disabled = "disabled",
3583 None = "none",
3584 AlreadyHandled = "already-handled"
3585}
3586
3587/**
3588 * @public
3589 */
3590export declare interface InterceptResolutionState {
3591 action: InterceptResolutionAction;
3592 priority?: number;
3593}
3594
3595/**
3596 * @public
3597 */
3598export declare interface InternalNetworkConditions extends NetworkConditions {
3599 offline: boolean;
3600}
3601
3602/* Excluded from this release type: IntervalPoller */
3603
3604/* Excluded from this release type: isDate */
3605
3606/* Excluded from this release type: _isElementHandle */
3607
3608/* Excluded from this release type: isErrnoException */
3609
3610/* Excluded from this release type: isErrorLike */
3611
3612/* Excluded from this release type: isNumber */
3613
3614/* Excluded from this release type: IsolatedWorld */
3615
3616/* Excluded from this release type: IsolatedWorldChart */
3617
3618/* Excluded from this release type: IsolatedWorldEmitter */
3619
3620/* Excluded from this release type: IsPageTargetCallback */
3621
3622/* Excluded from this release type: isPlainObject */
3623
3624/* Excluded from this release type: isRegExp */
3625
3626/* Excluded from this release type: isString */
3627
3628/* Excluded from this release type: isTargetClosedError */
3629
3630/**
3631 * @public
3632 */
3633export declare class JSCoverage {
3634 #private;
3635 /* Excluded from this release type: __constructor */
3636 /* Excluded from this release type: updateClient */
3637 start(options?: {
3638 resetOnNavigation?: boolean;
3639 reportAnonymousScripts?: boolean;
3640 includeRawScriptCoverage?: boolean;
3641 useBlockCoverage?: boolean;
3642 }): Promise<void>;
3643 stop(): Promise<JSCoverageEntry[]>;
3644}
3645
3646/**
3647 * The CoverageEntry class for JavaScript
3648 * @public
3649 */
3650export declare interface JSCoverageEntry extends CoverageEntry {
3651 /**
3652 * Raw V8 script coverage entry.
3653 */
3654 rawScriptCoverage?: Protocol.Profiler.ScriptCoverage;
3655}
3656
3657/**
3658 * Set of configurable options for JS coverage.
3659 * @public
3660 */
3661export declare interface JSCoverageOptions {
3662 /**
3663 * Whether to reset coverage on every navigation.
3664 */
3665 resetOnNavigation?: boolean;
3666 /**
3667 * Whether anonymous scripts generated by the page should be reported.
3668 */
3669 reportAnonymousScripts?: boolean;
3670 /**
3671 * Whether the result includes raw V8 script coverage entries.
3672 */
3673 includeRawScriptCoverage?: boolean;
3674 /**
3675 * Whether to collect coverage information at the block level.
3676 * If true, coverage will be collected at the block level (this is the default).
3677 * If false, coverage will be collected at the function level.
3678 */
3679 useBlockCoverage?: boolean;
3680}
3681
3682/**
3683 * Represents a reference to a JavaScript object. Instances can be created using
3684 * {@link Page.evaluateHandle}.
3685 *
3686 * Handles prevent the referenced JavaScript object from being garbage-collected
3687 * unless the handle is purposely {@link JSHandle.dispose | disposed}. JSHandles
3688 * are auto-disposed when their associated frame is navigated away or the parent
3689 * context gets destroyed.
3690 *
3691 * Handles can be used as arguments for any evaluation function such as
3692 * {@link Page.$eval}, {@link Page.evaluate}, and {@link Page.evaluateHandle}.
3693 * They are resolved to their referenced object.
3694 *
3695 * @example
3696 *
3697 * ```ts
3698 * const windowHandle = await page.evaluateHandle(() => window);
3699 * ```
3700 *
3701 * @public
3702 */
3703export declare abstract class JSHandle<T = unknown> {
3704 move: () => this;
3705 /**
3706 * Used for nominally typing {@link JSHandle}.
3707 */
3708 _?: T;
3709 /* Excluded from this release type: __constructor */
3710 /* Excluded from this release type: realm */
3711 /* Excluded from this release type: disposed */
3712 /**
3713 * Evaluates the given function with the current handle as its first argument.
3714 */
3715 evaluate<Params extends unknown[], Func extends EvaluateFuncWith<T, Params> = EvaluateFuncWith<T, Params>>(pageFunction: Func | string, ...args: Params): Promise<Awaited<ReturnType<Func>>>;
3716 /**
3717 * Evaluates the given function with the current handle as its first argument.
3718 *
3719 */
3720 evaluateHandle<Params extends unknown[], Func extends EvaluateFuncWith<T, Params> = EvaluateFuncWith<T, Params>>(pageFunction: Func | string, ...args: Params): Promise<HandleFor<Awaited<ReturnType<Func>>>>;
3721 /**
3722 * Fetches a single property from the referenced object.
3723 */
3724 getProperty<K extends keyof T>(propertyName: HandleOr<K>): Promise<HandleFor<T[K]>>;
3725 getProperty(propertyName: string): Promise<JSHandle<unknown>>;
3726 /**
3727 * Gets a map of handles representing the properties of the current handle.
3728 *
3729 * @example
3730 *
3731 * ```ts
3732 * const listHandle = await page.evaluateHandle(() => document.body.children);
3733 * const properties = await listHandle.getProperties();
3734 * const children = [];
3735 * for (const property of properties.values()) {
3736 * const element = property.asElement();
3737 * if (element) {
3738 * children.push(element);
3739 * }
3740 * }
3741 * children; // holds elementHandles to all children of document.body
3742 * ```
3743 */
3744 getProperties(): Promise<Map<string, JSHandle>>;
3745 /**
3746 * A vanilla object representing the serializable portions of the
3747 * referenced object.
3748 * @throws Throws if the object cannot be serialized due to circularity.
3749 *
3750 * @remarks
3751 * If the object has a `toJSON` function, it **will not** be called.
3752 */
3753 abstract jsonValue(): Promise<T>;
3754 /**
3755 * Either `null` or the handle itself if the handle is an
3756 * instance of {@link ElementHandle}.
3757 */
3758 abstract asElement(): ElementHandle<Node> | null;
3759 /**
3760 * Releases the object referenced by the handle for garbage collection.
3761 */
3762 abstract dispose(): Promise<void>;
3763 /**
3764 * Returns a string representation of the JSHandle.
3765 *
3766 * @remarks
3767 * Useful during debugging.
3768 */
3769 abstract toString(): string;
3770 /* Excluded from this release type: id */
3771 /**
3772 * Provides access to the
3773 * {@link https://chromedevtools.github.io/devtools-protocol/tot/Runtime/#type-RemoteObject | Protocol.Runtime.RemoteObject}
3774 * backing this handle.
3775 */
3776 abstract remoteObject(): Protocol.Runtime.RemoteObject;
3777 /* Excluded from this release type: [disposeSymbol] */
3778 /* Excluded from this release type: [asyncDisposeSymbol] */
3779}
3780
3781/**
3782 * Keyboard provides an api for managing a virtual keyboard.
3783 * The high level api is {@link Keyboard."type"},
3784 * which takes raw characters and generates proper keydown, keypress/input,
3785 * and keyup events on your page.
3786 *
3787 * @remarks
3788 * For finer control, you can use {@link Keyboard.down},
3789 * {@link Keyboard.up}, and {@link Keyboard.sendCharacter}
3790 * to manually fire events as if they were generated from a real keyboard.
3791 *
3792 * On macOS, keyboard shortcuts like `⌘ A` -\> Select All do not work.
3793 * See {@link https://github.com/puppeteer/puppeteer/issues/1313 | #1313}.
3794 *
3795 * @example
3796 * An example of holding down `Shift` in order to select and delete some text:
3797 *
3798 * ```ts
3799 * await page.keyboard.type('Hello World!');
3800 * await page.keyboard.press('ArrowLeft');
3801 *
3802 * await page.keyboard.down('Shift');
3803 * for (let i = 0; i < ' World'.length; i++)
3804 * await page.keyboard.press('ArrowLeft');
3805 * await page.keyboard.up('Shift');
3806 *
3807 * await page.keyboard.press('Backspace');
3808 * // Result text will end up saying 'Hello!'
3809 * ```
3810 *
3811 * @example
3812 * An example of pressing `A`
3813 *
3814 * ```ts
3815 * await page.keyboard.down('Shift');
3816 * await page.keyboard.press('KeyA');
3817 * await page.keyboard.up('Shift');
3818 * ```
3819 *
3820 * @public
3821 */
3822export declare abstract class Keyboard {
3823 /* Excluded from this release type: __constructor */
3824 /**
3825 * Dispatches a `keydown` event.
3826 *
3827 * @remarks
3828 * If `key` is a single character and no modifier keys besides `Shift`
3829 * are being held down, a `keypress`/`input` event will also generated.
3830 * The `text` option can be specified to force an input event to be generated.
3831 * If `key` is a modifier key, `Shift`, `Meta`, `Control`, or `Alt`,
3832 * subsequent key presses will be sent with that modifier active.
3833 * To release the modifier key, use {@link Keyboard.up}.
3834 *
3835 * After the key is pressed once, subsequent calls to
3836 * {@link Keyboard.down} will have
3837 * {@link https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/repeat | repeat}
3838 * set to true. To release the key, use {@link Keyboard.up}.
3839 *
3840 * Modifier keys DO influence {@link Keyboard.down}.
3841 * Holding down `Shift` will type the text in upper case.
3842 *
3843 * @param key - Name of key to press, such as `ArrowLeft`.
3844 * See {@link KeyInput} for a list of all key names.
3845 *
3846 * @param options - An object of options. Accepts text which, if specified,
3847 * generates an input event with this text. Accepts commands which, if specified,
3848 * is the commands of keyboard shortcuts,
3849 * see {@link https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/editing/commands/editor_command_names.h | Chromium Source Code} for valid command names.
3850 */
3851 abstract down(key: KeyInput, options?: Readonly<KeyDownOptions>): Promise<void>;
3852 /**
3853 * Dispatches a `keyup` event.
3854 *
3855 * @param key - Name of key to release, such as `ArrowLeft`.
3856 * See {@link KeyInput | KeyInput}
3857 * for a list of all key names.
3858 */
3859 abstract up(key: KeyInput): Promise<void>;
3860 /**
3861 * Dispatches a `keypress` and `input` event.
3862 * This does not send a `keydown` or `keyup` event.
3863 *
3864 * @remarks
3865 * Modifier keys DO NOT effect {@link Keyboard.sendCharacter | Keyboard.sendCharacter}.
3866 * Holding down `Shift` will not type the text in upper case.
3867 *
3868 * @example
3869 *
3870 * ```ts
3871 * page.keyboard.sendCharacter('嗨');
3872 * ```
3873 *
3874 * @param char - Character to send into the page.
3875 */
3876 abstract sendCharacter(char: string): Promise<void>;
3877 /**
3878 * Sends a `keydown`, `keypress`/`input`,
3879 * and `keyup` event for each character in the text.
3880 *
3881 * @remarks
3882 * To press a special key, like `Control` or `ArrowDown`,
3883 * use {@link Keyboard.press}.
3884 *
3885 * Modifier keys DO NOT effect `keyboard.type`.
3886 * Holding down `Shift` will not type the text in upper case.
3887 *
3888 * @example
3889 *
3890 * ```ts
3891 * await page.keyboard.type('Hello'); // Types instantly
3892 * await page.keyboard.type('World', {delay: 100}); // Types slower, like a user
3893 * ```
3894 *
3895 * @param text - A text to type into a focused element.
3896 * @param options - An object of options. Accepts delay which,
3897 * if specified, is the time to wait between `keydown` and `keyup` in milliseconds.
3898 * Defaults to 0.
3899 */
3900 abstract type(text: string, options?: Readonly<KeyboardTypeOptions>): Promise<void>;
3901 /**
3902 * Shortcut for {@link Keyboard.down}
3903 * and {@link Keyboard.up}.
3904 *
3905 * @remarks
3906 * If `key` is a single character and no modifier keys besides `Shift`
3907 * are being held down, a `keypress`/`input` event will also generated.
3908 * The `text` option can be specified to force an input event to be generated.
3909 *
3910 * Modifier keys DO effect {@link Keyboard.press}.
3911 * Holding down `Shift` will type the text in upper case.
3912 *
3913 * @param key - Name of key to press, such as `ArrowLeft`.
3914 * See {@link KeyInput} for a list of all key names.
3915 *
3916 * @param options - An object of options. Accepts text which, if specified,
3917 * generates an input event with this text. Accepts delay which,
3918 * if specified, is the time to wait between `keydown` and `keyup` in milliseconds.
3919 * Defaults to 0. Accepts commands which, if specified,
3920 * is the commands of keyboard shortcuts,
3921 * see {@link https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/editing/commands/editor_command_names.h | Chromium Source Code} for valid command names.
3922 */
3923 abstract press(key: KeyInput, options?: Readonly<KeyPressOptions>): Promise<void>;
3924}
3925
3926/**
3927 * @public
3928 */
3929export declare interface KeyboardTypeOptions {
3930 delay?: number;
3931}
3932
3933/* Excluded from this release type: KeyDefinition */
3934
3935/* Excluded from this release type: _keyDefinitions */
3936
3937/**
3938 * @public
3939 */
3940export declare interface KeyDownOptions {
3941 /**
3942 * @deprecated Do not use. This is automatically handled.
3943 */
3944 text?: string;
3945 /**
3946 * @deprecated Do not use. This is automatically handled.
3947 */
3948 commands?: string[];
3949}
3950
3951/**
3952 * All the valid keys that can be passed to functions that take user input, such
3953 * as {@link Keyboard.press | keyboard.press }
3954 *
3955 * @public
3956 */
3957export declare type KeyInput = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | 'Power' | 'Eject' | 'Abort' | 'Help' | 'Backspace' | 'Tab' | 'Numpad5' | 'NumpadEnter' | 'Enter' | '\r' | '\n' | 'ShiftLeft' | 'ShiftRight' | 'ControlLeft' | 'ControlRight' | 'AltLeft' | 'AltRight' | 'Pause' | 'CapsLock' | 'Escape' | 'Convert' | 'NonConvert' | 'Space' | 'Numpad9' | 'PageUp' | 'Numpad3' | 'PageDown' | 'End' | 'Numpad1' | 'Home' | 'Numpad7' | 'ArrowLeft' | 'Numpad4' | 'Numpad8' | 'ArrowUp' | 'ArrowRight' | 'Numpad6' | 'Numpad2' | 'ArrowDown' | 'Select' | 'Open' | 'PrintScreen' | 'Insert' | 'Numpad0' | 'Delete' | 'NumpadDecimal' | 'Digit0' | 'Digit1' | 'Digit2' | 'Digit3' | 'Digit4' | 'Digit5' | 'Digit6' | 'Digit7' | 'Digit8' | 'Digit9' | 'KeyA' | 'KeyB' | 'KeyC' | 'KeyD' | 'KeyE' | 'KeyF' | 'KeyG' | 'KeyH' | 'KeyI' | 'KeyJ' | 'KeyK' | 'KeyL' | 'KeyM' | 'KeyN' | 'KeyO' | 'KeyP' | 'KeyQ' | 'KeyR' | 'KeyS' | 'KeyT' | 'KeyU' | 'KeyV' | 'KeyW' | 'KeyX' | 'KeyY' | 'KeyZ' | 'MetaLeft' | 'MetaRight' | 'ContextMenu' | 'NumpadMultiply' | 'NumpadAdd' | 'NumpadSubtract' | 'NumpadDivide' | 'F1' | 'F2' | 'F3' | 'F4' | 'F5' | 'F6' | 'F7' | 'F8' | 'F9' | 'F10' | 'F11' | 'F12' | 'F13' | 'F14' | 'F15' | 'F16' | 'F17' | 'F18' | 'F19' | 'F20' | 'F21' | 'F22' | 'F23' | 'F24' | 'NumLock' | 'ScrollLock' | 'AudioVolumeMute' | 'AudioVolumeDown' | 'AudioVolumeUp' | 'MediaTrackNext' | 'MediaTrackPrevious' | 'MediaStop' | 'MediaPlayPause' | 'Semicolon' | 'Equal' | 'NumpadEqual' | 'Comma' | 'Minus' | 'Period' | 'Slash' | 'Backquote' | 'BracketLeft' | 'Backslash' | 'BracketRight' | 'Quote' | 'AltGraph' | 'Props' | 'Cancel' | 'Clear' | 'Shift' | 'Control' | 'Alt' | 'Accept' | 'ModeChange' | ' ' | 'Print' | 'Execute' | '\u0000' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z' | 'Meta' | '*' | '+' | '-' | '/' | ';' | '=' | ',' | '.' | '`' | '[' | '\\' | ']' | "'" | 'Attn' | 'CrSel' | 'ExSel' | 'EraseEof' | 'Play' | 'ZoomOut' | ')' | '!' | '@' | '#' | '$' | '%' | '^' | '&' | '(' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z' | ':' | '<' | '_' | '>' | '?' | '~' | '{' | '|' | '}' | '"' | 'SoftLeft' | 'SoftRight' | 'Camera' | 'Call' | 'EndCall' | 'VolumeDown' | 'VolumeUp';
3958
3959/**
3960 * @public
3961 */
3962export declare type KeyPressOptions = KeyDownOptions & KeyboardTypeOptions;
3963
3964/**
3965 * A list of devices to be used with {@link Page.emulate}.
3966 *
3967 * @example
3968 *
3969 * ```ts
3970 * import {KnownDevices} from 'puppeteer';
3971 * const iPhone = KnownDevices['iPhone 15 Pro'];
3972 *
3973 * (async () => {
3974 * const browser = await puppeteer.launch();
3975 * const page = await browser.newPage();
3976 * await page.emulate(iPhone);
3977 * await page.goto('https://www.google.com');
3978 * // other actions...
3979 * await browser.close();
3980 * })();
3981 * ```
3982 *
3983 * @public
3984 */
3985export declare const KnownDevices: Readonly<Record<"Blackberry PlayBook" | "Blackberry PlayBook landscape" | "BlackBerry Z30" | "BlackBerry Z30 landscape" | "Galaxy Note 3" | "Galaxy Note 3 landscape" | "Galaxy Note II" | "Galaxy Note II landscape" | "Galaxy S III" | "Galaxy S III landscape" | "Galaxy S5" | "Galaxy S5 landscape" | "Galaxy S8" | "Galaxy S8 landscape" | "Galaxy S9+" | "Galaxy S9+ landscape" | "Galaxy Tab S4" | "Galaxy Tab S4 landscape" | "iPad" | "iPad landscape" | "iPad (gen 6)" | "iPad (gen 6) landscape" | "iPad (gen 7)" | "iPad (gen 7) landscape" | "iPad Mini" | "iPad Mini landscape" | "iPad Pro" | "iPad Pro landscape" | "iPad Pro 11" | "iPad Pro 11 landscape" | "iPhone 4" | "iPhone 4 landscape" | "iPhone 5" | "iPhone 5 landscape" | "iPhone 6" | "iPhone 6 landscape" | "iPhone 6 Plus" | "iPhone 6 Plus landscape" | "iPhone 7" | "iPhone 7 landscape" | "iPhone 7 Plus" | "iPhone 7 Plus landscape" | "iPhone 8" | "iPhone 8 landscape" | "iPhone 8 Plus" | "iPhone 8 Plus landscape" | "iPhone SE" | "iPhone SE landscape" | "iPhone X" | "iPhone X landscape" | "iPhone XR" | "iPhone XR landscape" | "iPhone 11" | "iPhone 11 landscape" | "iPhone 11 Pro" | "iPhone 11 Pro landscape" | "iPhone 11 Pro Max" | "iPhone 11 Pro Max landscape" | "iPhone 12" | "iPhone 12 landscape" | "iPhone 12 Pro" | "iPhone 12 Pro landscape" | "iPhone 12 Pro Max" | "iPhone 12 Pro Max landscape" | "iPhone 12 Mini" | "iPhone 12 Mini landscape" | "iPhone 13" | "iPhone 13 landscape" | "iPhone 13 Pro" | "iPhone 13 Pro landscape" | "iPhone 13 Pro Max" | "iPhone 13 Pro Max landscape" | "iPhone 13 Mini" | "iPhone 13 Mini landscape" | "iPhone 14" | "iPhone 14 landscape" | "iPhone 14 Plus" | "iPhone 14 Plus landscape" | "iPhone 14 Pro" | "iPhone 14 Pro landscape" | "iPhone 14 Pro Max" | "iPhone 14 Pro Max landscape" | "iPhone 15" | "iPhone 15 landscape" | "iPhone 15 Plus" | "iPhone 15 Plus landscape" | "iPhone 15 Pro" | "iPhone 15 Pro landscape" | "iPhone 15 Pro Max" | "iPhone 15 Pro Max landscape" | "JioPhone 2" | "JioPhone 2 landscape" | "Kindle Fire HDX" | "Kindle Fire HDX landscape" | "LG Optimus L70" | "LG Optimus L70 landscape" | "Microsoft Lumia 550" | "Microsoft Lumia 950" | "Microsoft Lumia 950 landscape" | "Nexus 10" | "Nexus 10 landscape" | "Nexus 4" | "Nexus 4 landscape" | "Nexus 5" | "Nexus 5 landscape" | "Nexus 5X" | "Nexus 5X landscape" | "Nexus 6" | "Nexus 6 landscape" | "Nexus 6P" | "Nexus 6P landscape" | "Nexus 7" | "Nexus 7 landscape" | "Nokia Lumia 520" | "Nokia Lumia 520 landscape" | "Nokia N9" | "Nokia N9 landscape" | "Pixel 2" | "Pixel 2 landscape" | "Pixel 2 XL" | "Pixel 2 XL landscape" | "Pixel 3" | "Pixel 3 landscape" | "Pixel 4" | "Pixel 4 landscape" | "Pixel 4a (5G)" | "Pixel 4a (5G) landscape" | "Pixel 5" | "Pixel 5 landscape" | "Moto G4" | "Moto G4 landscape", Device>>;
3986
3987/**
3988 * @public
3989 */
3990export declare const
3991/**
3992* @public
3993*/
3994/**
3995 * @public
3996 */
3997launch: (options?: PuppeteerLaunchOptions | undefined) => Promise<Browser>;
3998
3999/**
4000 * Generic launch options that can be passed when launching any browser.
4001 * @public
4002 */
4003export declare interface LaunchOptions {
4004 /**
4005 * Chrome Release Channel
4006 */
4007 channel?: ChromeReleaseChannel;
4008 /**
4009 * Path to a browser executable to use instead of the bundled browser. Note
4010 * that Puppeteer is only guaranteed to work with the bundled browser, so use
4011 * this setting at your own risk.
4012 *
4013 * @remarks
4014 * When using this is recommended to set the `browser` property as well
4015 * as Puppeteer will default to `chrome` by default.
4016 */
4017 executablePath?: string;
4018 /**
4019 * If `true`, do not use `puppeteer.defaultArgs()` when creating a browser. If
4020 * an array is provided, these args will be filtered out. Use this with care -
4021 * you probably want the default arguments Puppeteer uses.
4022 * @defaultValue `false`
4023 */
4024 ignoreDefaultArgs?: boolean | string[];
4025 /**
4026 * Close the browser process on `Ctrl+C`.
4027 * @defaultValue `true`
4028 */
4029 handleSIGINT?: boolean;
4030 /**
4031 * Close the browser process on `SIGTERM`.
4032 * @defaultValue `true`
4033 */
4034 handleSIGTERM?: boolean;
4035 /**
4036 * Close the browser process on `SIGHUP`.
4037 * @defaultValue `true`
4038 */
4039 handleSIGHUP?: boolean;
4040 /**
4041 * Maximum time in milliseconds to wait for the browser to start.
4042 * Pass `0` to disable the timeout.
4043 * @defaultValue `30_000` (30 seconds).
4044 */
4045 timeout?: number;
4046 /**
4047 * If true, pipes the browser process stdout and stderr to `process.stdout`
4048 * and `process.stderr`.
4049 * @defaultValue `false`
4050 */
4051 dumpio?: boolean;
4052 /**
4053 * Specify environment variables that will be visible to the browser.
4054 * @defaultValue The contents of `process.env`.
4055 */
4056 env?: Record<string, string | undefined>;
4057 /**
4058 * Connect to a browser over a pipe instead of a WebSocket. Only supported
4059 * with Chrome.
4060 *
4061 * @defaultValue `false`
4062 */
4063 pipe?: boolean;
4064 /**
4065 * Which browser to launch.
4066 * @defaultValue `chrome`
4067 */
4068 browser?: SupportedBrowser;
4069 /**
4070 * {@link https://searchfox.org/mozilla-release/source/modules/libpref/init/all.js | Additional preferences } that can be passed when launching with Firefox.
4071 */
4072 extraPrefsFirefox?: Record<string, unknown>;
4073 /**
4074 * Whether to wait for the initial page to be ready.
4075 * Useful when a user explicitly disables that (e.g. `--no-startup-window` for Chrome).
4076 * @defaultValue `true`
4077 */
4078 waitForInitialPage?: boolean;
4079}
4080
4081/* Excluded from this release type: LazyArg */
4082
4083/* Excluded from this release type: LifecycleWatcher */
4084
4085/**
4086 * Locators describe a strategy of locating objects and performing an action on
4087 * them. If the action fails because the object is not ready for the action, the
4088 * whole operation is retried. Various preconditions for a successful action are
4089 * checked automatically.
4090 *
4091 * See {@link https://pptr.dev/guides/page-interactions#locators} for details.
4092 *
4093 * @public
4094 */
4095export declare abstract class Locator<T> extends EventEmitter<LocatorEvents> {
4096 #private;
4097 /**
4098 * Creates a race between multiple locators trying to locate elements in
4099 * parallel but ensures that only a single element receives the action.
4100 *
4101 * @public
4102 */
4103 static race<Locators extends readonly unknown[] | []>(locators: Locators): Locator<AwaitedLocator<Locators[number]>>;
4104 /**
4105 * Used for nominally typing {@link Locator}.
4106 */
4107 _?: T;
4108 /* Excluded from this release type: visibility */
4109 /* Excluded from this release type: _timeout */
4110 /* Excluded from this release type: operators */
4111 get timeout(): number;
4112 /**
4113 * Creates a new locator instance by cloning the current locator and setting
4114 * the total timeout for the locator actions.
4115 *
4116 * Pass `0` to disable timeout.
4117 *
4118 * @defaultValue `Page.getDefaultTimeout()`
4119 */
4120 setTimeout(timeout: number): Locator<T>;
4121 /**
4122 * Creates a new locator instance by cloning the current locator with the
4123 * visibility property changed to the specified value.
4124 */
4125 setVisibility<NodeType extends Node>(this: Locator<NodeType>, visibility: VisibilityOption): Locator<NodeType>;
4126 /**
4127 * Creates a new locator instance by cloning the current locator and
4128 * specifying whether to wait for input elements to become enabled before the
4129 * action. Applicable to `click` and `fill` actions.
4130 *
4131 * @defaultValue `true`
4132 */
4133 setWaitForEnabled<NodeType extends Node>(this: Locator<NodeType>, value: boolean): Locator<NodeType>;
4134 /**
4135 * Creates a new locator instance by cloning the current locator and
4136 * specifying whether the locator should scroll the element into viewport if
4137 * it is not in the viewport already.
4138 *
4139 * @defaultValue `true`
4140 */
4141 setEnsureElementIsInTheViewport<ElementType extends Element>(this: Locator<ElementType>, value: boolean): Locator<ElementType>;
4142 /**
4143 * Creates a new locator instance by cloning the current locator and
4144 * specifying whether the locator has to wait for the element's bounding box
4145 * to be same between two consecutive animation frames.
4146 *
4147 * @defaultValue `true`
4148 */
4149 setWaitForStableBoundingBox<ElementType extends Element>(this: Locator<ElementType>, value: boolean): Locator<ElementType>;
4150 /* Excluded from this release type: copyOptions */
4151 /* Excluded from this release type: _clone */
4152 /* Excluded from this release type: _wait */
4153 /**
4154 * Clones the locator.
4155 */
4156 clone(): Locator<T>;
4157 /**
4158 * Waits for the locator to get a handle from the page.
4159 *
4160 * @public
4161 */
4162 waitHandle(options?: Readonly<ActionOptions>): Promise<HandleFor<T>>;
4163 /**
4164 * Waits for the locator to get the serialized value from the page.
4165 *
4166 * Note this requires the value to be JSON-serializable.
4167 *
4168 * @public
4169 */
4170 wait(options?: Readonly<ActionOptions>): Promise<T>;
4171 /**
4172 * Maps the locator using the provided mapper.
4173 *
4174 * @public
4175 */
4176 map<To>(mapper: Mapper<T, To>): Locator<To>;
4177 /**
4178 * Creates an expectation that is evaluated against located values.
4179 *
4180 * If the expectations do not match, then the locator will retry.
4181 *
4182 * @public
4183 */
4184 filter<S extends T>(predicate: Predicate<T, S>): Locator<S>;
4185 /* Excluded from this release type: filterHandle */
4186 /* Excluded from this release type: mapHandle */
4187 /**
4188 * Clicks the located element.
4189 */
4190 click<ElementType extends Element>(this: Locator<ElementType>, options?: Readonly<LocatorClickOptions>): Promise<void>;
4191 /**
4192 * Fills out the input identified by the locator using the provided value. The
4193 * type of the input is determined at runtime and the appropriate fill-out
4194 * method is chosen based on the type. `contenteditable`, select, textarea and
4195 * input elements are supported.
4196 */
4197 fill<ElementType extends Element>(this: Locator<ElementType>, value: string, options?: Readonly<ActionOptions>): Promise<void>;
4198 /**
4199 * Hovers over the located element.
4200 */
4201 hover<ElementType extends Element>(this: Locator<ElementType>, options?: Readonly<ActionOptions>): Promise<void>;
4202 /**
4203 * Scrolls the located element.
4204 */
4205 scroll<ElementType extends Element>(this: Locator<ElementType>, options?: Readonly<LocatorScrollOptions>): Promise<void>;
4206}
4207
4208/**
4209 * @public
4210 */
4211export declare type LocatorClickOptions = ClickOptions & ActionOptions;
4212
4213/**
4214 * All the events that a locator instance may emit.
4215 *
4216 * @public
4217 */
4218export declare enum LocatorEvent {
4219 /**
4220 * Emitted every time before the locator performs an action on the located element(s).
4221 */
4222 Action = "action"
4223}
4224
4225/**
4226 * @public
4227 */
4228export declare interface LocatorEvents extends Record<EventType, unknown> {
4229 [LocatorEvent.Action]: undefined;
4230}
4231
4232/**
4233 * @public
4234 */
4235export declare interface LocatorScrollOptions extends ActionOptions {
4236 scrollTop?: number;
4237 scrollLeft?: number;
4238}
4239
4240/**
4241 * @public
4242 */
4243export declare type LowerCasePaperFormat = 'letter' | 'legal' | 'tabloid' | 'ledger' | 'a0' | 'a1' | 'a2' | 'a3' | 'a4' | 'a5' | 'a6';
4244
4245/* Excluded from this release type: MAIN_WORLD */
4246
4247/* Excluded from this release type: MappedLocator */
4248
4249/**
4250 * @public
4251 */
4252export declare type Mapper<From, To> = (value: From) => Awaitable<To>;
4253
4254/**
4255 * A media feature to emulate.
4256 *
4257 * @public
4258 */
4259export declare interface MediaFeature {
4260 /**
4261 * A name of the feature, for example, 'prefers-reduced-motion'.
4262 */
4263 name: string;
4264 /**
4265 * A value for the feature, for example, 'reduce'.
4266 */
4267 value: string;
4268}
4269
4270/**
4271 * @public
4272 */
4273export declare interface Metrics {
4274 Timestamp?: number;
4275 Documents?: number;
4276 Frames?: number;
4277 JSEventListeners?: number;
4278 Nodes?: number;
4279 LayoutCount?: number;
4280 RecalcStyleCount?: number;
4281 LayoutDuration?: number;
4282 RecalcStyleDuration?: number;
4283 ScriptDuration?: number;
4284 TaskDuration?: number;
4285 JSHeapUsedSize?: number;
4286 JSHeapTotalSize?: number;
4287}
4288
4289/**
4290 * The Mouse class operates in main-frame CSS pixels
4291 * relative to the top-left corner of the viewport.
4292 *
4293 * @remarks
4294 * Every `page` object has its own Mouse, accessible with {@link Page.mouse}.
4295 *
4296 * @example
4297 *
4298 * ```ts
4299 * // Using ‘page.mouse’ to trace a 100x100 square.
4300 * await page.mouse.move(0, 0);
4301 * await page.mouse.down();
4302 * await page.mouse.move(0, 100);
4303 * await page.mouse.move(100, 100);
4304 * await page.mouse.move(100, 0);
4305 * await page.mouse.move(0, 0);
4306 * await page.mouse.up();
4307 * ```
4308 *
4309 * **Note**: The mouse events trigger synthetic `MouseEvent`s.
4310 * This means that it does not fully replicate the functionality of what a normal user
4311 * would be able to do with their mouse.
4312 *
4313 * For example, dragging and selecting text is not possible using `page.mouse`.
4314 * Instead, you can use the {@link https://developer.mozilla.org/en-US/docs/Web/API/DocumentOrShadowRoot/getSelection | `DocumentOrShadowRoot.getSelection()`} functionality implemented in the platform.
4315 *
4316 * @example
4317 * For example, if you want to select all content between nodes:
4318 *
4319 * ```ts
4320 * await page.evaluate(
4321 * (from, to) => {
4322 * const selection = from.getRootNode().getSelection();
4323 * const range = document.createRange();
4324 * range.setStartBefore(from);
4325 * range.setEndAfter(to);
4326 * selection.removeAllRanges();
4327 * selection.addRange(range);
4328 * },
4329 * fromJSHandle,
4330 * toJSHandle
4331 * );
4332 * ```
4333 *
4334 * If you then would want to copy-paste your selection, you can use the clipboard api:
4335 *
4336 * ```ts
4337 * // The clipboard api does not allow you to copy, unless the tab is focused.
4338 * await page.bringToFront();
4339 * await page.evaluate(() => {
4340 * // Copy the selected content to the clipboard
4341 * document.execCommand('copy');
4342 * // Obtain the content of the clipboard as a string
4343 * return navigator.clipboard.readText();
4344 * });
4345 * ```
4346 *
4347 * **Note**: If you want access to the clipboard API,
4348 * you have to give it permission to do so:
4349 *
4350 * ```ts
4351 * await browser
4352 * .defaultBrowserContext()
4353 * .overridePermissions('<your origin>', [
4354 * 'clipboard-read',
4355 * 'clipboard-write',
4356 * ]);
4357 * ```
4358 *
4359 * @public
4360 */
4361export declare abstract class Mouse {
4362 /* Excluded from this release type: __constructor */
4363 /**
4364 * Resets the mouse to the default state: No buttons pressed; position at
4365 * (0,0).
4366 */
4367 abstract reset(): Promise<void>;
4368 /**
4369 * Moves the mouse to the given coordinate.
4370 *
4371 * @param x - Horizontal position of the mouse.
4372 * @param y - Vertical position of the mouse.
4373 * @param options - Options to configure behavior.
4374 */
4375 abstract move(x: number, y: number, options?: Readonly<MouseMoveOptions>): Promise<void>;
4376 /**
4377 * Presses the mouse.
4378 *
4379 * @param options - Options to configure behavior.
4380 */
4381 abstract down(options?: Readonly<MouseOptions>): Promise<void>;
4382 /**
4383 * Releases the mouse.
4384 *
4385 * @param options - Options to configure behavior.
4386 */
4387 abstract up(options?: Readonly<MouseOptions>): Promise<void>;
4388 /**
4389 * Shortcut for `mouse.move`, `mouse.down` and `mouse.up`.
4390 *
4391 * @param x - Horizontal position of the mouse.
4392 * @param y - Vertical position of the mouse.
4393 * @param options - Options to configure behavior.
4394 */
4395 abstract click(x: number, y: number, options?: Readonly<MouseClickOptions>): Promise<void>;
4396 /**
4397 * Dispatches a `mousewheel` event.
4398 * @param options - Optional: `MouseWheelOptions`.
4399 *
4400 * @example
4401 * An example of zooming into an element:
4402 *
4403 * ```ts
4404 * await page.goto(
4405 * 'https://mdn.mozillademos.org/en-US/docs/Web/API/Element/wheel_event$samples/Scaling_an_element_via_the_wheel?revision=1587366'
4406 * );
4407 *
4408 * const elem = await page.$('div');
4409 * const boundingBox = await elem.boundingBox();
4410 * await page.mouse.move(
4411 * boundingBox.x + boundingBox.width / 2,
4412 * boundingBox.y + boundingBox.height / 2
4413 * );
4414 *
4415 * await page.mouse.wheel({deltaY: -100});
4416 * ```
4417 */
4418 abstract wheel(options?: Readonly<MouseWheelOptions>): Promise<void>;
4419 /**
4420 * Dispatches a `drag` event.
4421 * @param start - starting point for drag
4422 * @param target - point to drag to
4423 */
4424 abstract drag(start: Point, target: Point): Promise<Protocol.Input.DragData>;
4425 /**
4426 * Dispatches a `dragenter` event.
4427 * @param target - point for emitting `dragenter` event
4428 * @param data - drag data containing items and operations mask
4429 */
4430 abstract dragEnter(target: Point, data: Protocol.Input.DragData): Promise<void>;
4431 /**
4432 * Dispatches a `dragover` event.
4433 * @param target - point for emitting `dragover` event
4434 * @param data - drag data containing items and operations mask
4435 */
4436 abstract dragOver(target: Point, data: Protocol.Input.DragData): Promise<void>;
4437 /**
4438 * Performs a dragenter, dragover, and drop in sequence.
4439 * @param target - point to drop on
4440 * @param data - drag data containing items and operations mask
4441 */
4442 abstract drop(target: Point, data: Protocol.Input.DragData): Promise<void>;
4443 /**
4444 * Performs a drag, dragenter, dragover, and drop in sequence.
4445 * @param start - point to drag from
4446 * @param target - point to drop on
4447 * @param options - An object of options. Accepts delay which,
4448 * if specified, is the time to wait between `dragover` and `drop` in milliseconds.
4449 * Defaults to 0.
4450 */
4451 abstract dragAndDrop(start: Point, target: Point, options?: {
4452 delay?: number;
4453 }): Promise<void>;
4454}
4455
4456/**
4457 * Enum of valid mouse buttons.
4458 *
4459 * @public
4460 */
4461export declare const MouseButton: Readonly<{
4462 Left: "left";
4463 Right: "right";
4464 Middle: "middle";
4465 Back: "back";
4466 Forward: "forward";
4467}>;
4468
4469/**
4470 * @public
4471 */
4472export declare type MouseButton = (typeof MouseButton)[keyof typeof MouseButton];
4473
4474/**
4475 * @public
4476 */
4477export declare interface MouseClickOptions extends MouseOptions {
4478 /**
4479 * Time (in ms) to delay the mouse release after the mouse press.
4480 */
4481 delay?: number;
4482 /**
4483 * Number of clicks to perform.
4484 *
4485 * @defaultValue `1`
4486 */
4487 count?: number;
4488}
4489
4490/**
4491 * @public
4492 */
4493export declare interface MouseMoveOptions {
4494 /**
4495 * Determines the number of movements to make from the current mouse position
4496 * to the new one.
4497 *
4498 * @defaultValue `1`
4499 */
4500 steps?: number;
4501}
4502
4503/**
4504 * @public
4505 */
4506export declare interface MouseOptions {
4507 /**
4508 * Determines which button will be pressed.
4509 *
4510 * @defaultValue `'left'`
4511 */
4512 button?: MouseButton;
4513 /**
4514 * Determines the click count for the mouse event. This does not perform
4515 * multiple clicks.
4516 *
4517 * @deprecated Use {@link MouseClickOptions.count}.
4518 * @defaultValue `1`
4519 */
4520 clickCount?: number;
4521}
4522
4523/**
4524 * @public
4525 */
4526export declare interface MouseWheelOptions {
4527 deltaX?: number;
4528 deltaY?: number;
4529}
4530
4531/**
4532 * @public
4533 */
4534export declare interface Moveable {
4535 /**
4536 * Moves the resource when 'using'.
4537 */
4538 move(): this;
4539}
4540
4541/* Excluded from this release type: MutationPoller */
4542
4543/* Excluded from this release type: Mutex */
4544
4545/* Excluded from this release type: NETWORK_IDLE_TIME */
4546
4547/**
4548 * @public
4549 */
4550export declare interface NetworkConditions {
4551 /**
4552 * Download speed (bytes/s)
4553 */
4554 download: number;
4555 /**
4556 * Upload speed (bytes/s)
4557 */
4558 upload: number;
4559 /**
4560 * Latency (ms)
4561 */
4562 latency: number;
4563}
4564
4565/* Excluded from this release type: NetworkEventManager */
4566
4567/* Excluded from this release type: NetworkManager */
4568
4569/* Excluded from this release type: NetworkManagerEvent */
4570
4571/* Excluded from this release type: NetworkManagerEvents */
4572
4573/* Excluded from this release type: NetworkRequestId */
4574
4575/**
4576 * @public
4577 */
4578export declare interface NewDocumentScriptEvaluation {
4579 identifier: string;
4580}
4581
4582/**
4583 * @public
4584 */
4585export declare type NodeFor<ComplexSelector extends string> = ParseSelector<ComplexSelector>;
4586
4587/* Excluded from this release type: NodeLocator */
4588
4589/**
4590 * @public
4591 */
4592export declare interface Offset {
4593 /**
4594 * x-offset for the clickable point relative to the top-left corner of the border box.
4595 */
4596 x: number;
4597 /**
4598 * y-offset for the clickable point relative to the top-left corner of the border box.
4599 */
4600 y: number;
4601}
4602
4603/* Excluded from this release type: OtherTarget */
4604
4605/**
4606 * Page provides methods to interact with a single tab or
4607 * {@link https://developer.chrome.com/extensions/background_pages | extension background page}
4608 * in the browser.
4609 *
4610 * :::note
4611 *
4612 * One Browser instance might have multiple Page instances.
4613 *
4614 * :::
4615 *
4616 * @example
4617 * This example creates a page, navigates it to a URL, and then saves a screenshot:
4618 *
4619 * ```ts
4620 * import puppeteer from 'puppeteer';
4621 *
4622 * (async () => {
4623 * const browser = await puppeteer.launch();
4624 * const page = await browser.newPage();
4625 * await page.goto('https://example.com');
4626 * await page.screenshot({path: 'screenshot.png'});
4627 * await browser.close();
4628 * })();
4629 * ```
4630 *
4631 * The Page class extends from Puppeteer's {@link EventEmitter} class and will
4632 * emit various events which are documented in the {@link PageEvent} enum.
4633 *
4634 * @example
4635 * This example logs a message for a single page `load` event:
4636 *
4637 * ```ts
4638 * page.once('load', () => console.log('Page loaded!'));
4639 * ```
4640 *
4641 * To unsubscribe from events use the {@link EventEmitter.off} method:
4642 *
4643 * ```ts
4644 * function logRequest(interceptedRequest) {
4645 * console.log('A request was made:', interceptedRequest.url());
4646 * }
4647 * page.on('request', logRequest);
4648 * // Sometime later...
4649 * page.off('request', logRequest);
4650 * ```
4651 *
4652 * @public
4653 */
4654export declare abstract class Page extends EventEmitter<PageEvents> {
4655 #private;
4656 /* Excluded from this release type: _isDragging */
4657 /* Excluded from this release type: _timeoutSettings */
4658 /* Excluded from this release type: __constructor */
4659 /**
4660 * `true` if the service worker are being bypassed, `false` otherwise.
4661 */
4662 abstract isServiceWorkerBypassed(): boolean;
4663 /**
4664 * `true` if drag events are being intercepted, `false` otherwise.
4665 *
4666 * @deprecated We no longer support intercepting drag payloads. Use the new
4667 * drag APIs found on {@link ElementHandle} to drag (or just use the
4668 * {@link Page.mouse}).
4669 */
4670 abstract isDragInterceptionEnabled(): boolean;
4671 /**
4672 * `true` if the page has JavaScript enabled, `false` otherwise.
4673 */
4674 abstract isJavaScriptEnabled(): boolean;
4675 /* Excluded from this release type: on */
4676 /* Excluded from this release type: off */
4677 /**
4678 * This method is typically coupled with an action that triggers file
4679 * choosing.
4680 *
4681 * :::caution
4682 *
4683 * This must be called before the file chooser is launched. It will not return
4684 * a currently active file chooser.
4685 *
4686 * :::
4687 *
4688 * :::caution
4689 *
4690 * Interception of file dialogs triggered via DOM APIs such as
4691 * window.showOpenFilePicker is currently not supported.
4692 *
4693 * :::
4694 *
4695 * @remarks
4696 * In the "headful" browser, this method results in the native file picker
4697 * dialog `not showing up` for the user.
4698 *
4699 * @example
4700 * The following example clicks a button that issues a file chooser
4701 * and then responds with `/tmp/myfile.pdf` as if a user has selected this file.
4702 *
4703 * ```ts
4704 * const [fileChooser] = await Promise.all([
4705 * page.waitForFileChooser(),
4706 * page.click('#upload-file-button'),
4707 * // some button that triggers file selection
4708 * ]);
4709 * await fileChooser.accept(['/tmp/myfile.pdf']);
4710 * ```
4711 */
4712 abstract waitForFileChooser(options?: WaitTimeoutOptions): Promise<FileChooser>;
4713 /**
4714 * Sets the page's geolocation.
4715 *
4716 * @remarks
4717 * Consider using {@link BrowserContext.overridePermissions} to grant
4718 * permissions for the page to read its geolocation.
4719 *
4720 * @example
4721 *
4722 * ```ts
4723 * await page.setGeolocation({latitude: 59.95, longitude: 30.31667});
4724 * ```
4725 */
4726 abstract setGeolocation(options: GeolocationOptions): Promise<void>;
4727 /**
4728 * A target this page was created from.
4729 *
4730 * @deprecated Use {@link Page.createCDPSession} directly.
4731 */
4732 abstract target(): Target;
4733 /**
4734 * Get the browser the page belongs to.
4735 */
4736 abstract browser(): Browser;
4737 /**
4738 * Get the browser context that the page belongs to.
4739 */
4740 abstract browserContext(): BrowserContext;
4741 /**
4742 * The page's main frame.
4743 */
4744 abstract mainFrame(): Frame;
4745 /**
4746 * Creates a Chrome Devtools Protocol session attached to the page.
4747 */
4748 abstract createCDPSession(): Promise<CDPSession>;
4749 /**
4750 * {@inheritDoc Keyboard}
4751 */
4752 abstract get keyboard(): Keyboard;
4753 /**
4754 * {@inheritDoc Touchscreen}
4755 */
4756 abstract get touchscreen(): Touchscreen;
4757 /**
4758 * {@inheritDoc Coverage}
4759 */
4760 abstract get coverage(): Coverage;
4761 /**
4762 * {@inheritDoc Tracing}
4763 */
4764 abstract get tracing(): Tracing;
4765 /**
4766 * {@inheritDoc Accessibility}
4767 */
4768 get accessibility(): Accessibility;
4769 /**
4770 * An array of all frames attached to the page.
4771 */
4772 abstract frames(): Frame[];
4773 /**
4774 * All of the dedicated {@link
4775 * https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API |
4776 * WebWorkers} associated with the page.
4777 *
4778 * @remarks
4779 * This does not contain ServiceWorkers
4780 */
4781 abstract workers(): WebWorker[];
4782 /**
4783 * Activating request interception enables {@link HTTPRequest.abort},
4784 * {@link HTTPRequest.continue} and {@link HTTPRequest.respond} methods. This
4785 * provides the capability to modify network requests that are made by a page.
4786 *
4787 * Once request interception is enabled, every request will stall unless it's
4788 * continued, responded or aborted; or completed using the browser cache.
4789 *
4790 * See the
4791 * {@link https://pptr.dev/guides/network-interception|Request interception guide}
4792 * for more details.
4793 *
4794 * @example
4795 * An example of a naïve request interceptor that aborts all image requests:
4796 *
4797 * ```ts
4798 * import puppeteer from 'puppeteer';
4799 * (async () => {
4800 * const browser = await puppeteer.launch();
4801 * const page = await browser.newPage();
4802 * await page.setRequestInterception(true);
4803 * page.on('request', interceptedRequest => {
4804 * if (
4805 * interceptedRequest.url().endsWith('.png') ||
4806 * interceptedRequest.url().endsWith('.jpg')
4807 * )
4808 * interceptedRequest.abort();
4809 * else interceptedRequest.continue();
4810 * });
4811 * await page.goto('https://example.com');
4812 * await browser.close();
4813 * })();
4814 * ```
4815 *
4816 * @param value - Whether to enable request interception.
4817 */
4818 abstract setRequestInterception(value: boolean): Promise<void>;
4819 /**
4820 * Toggles ignoring of service worker for each request.
4821 *
4822 * @param bypass - Whether to bypass service worker and load from network.
4823 */
4824 abstract setBypassServiceWorker(bypass: boolean): Promise<void>;
4825 /**
4826 * @param enabled - Whether to enable drag interception.
4827 *
4828 * @deprecated We no longer support intercepting drag payloads. Use the new
4829 * drag APIs found on {@link ElementHandle} to drag (or just use the
4830 * {@link Page.mouse}).
4831 */
4832 abstract setDragInterception(enabled: boolean): Promise<void>;
4833 /**
4834 * Sets the network connection to offline.
4835 *
4836 * It does not change the parameters used in {@link Page.emulateNetworkConditions}
4837 *
4838 * @param enabled - When `true`, enables offline mode for the page.
4839 */
4840 abstract setOfflineMode(enabled: boolean): Promise<void>;
4841 /**
4842 * This does not affect WebSockets and WebRTC PeerConnections (see
4843 * https://crbug.com/563644). To set the page offline, you can use
4844 * {@link Page.setOfflineMode}.
4845 *
4846 * A list of predefined network conditions can be used by importing
4847 * {@link PredefinedNetworkConditions}.
4848 *
4849 * @example
4850 *
4851 * ```ts
4852 * import {PredefinedNetworkConditions} from 'puppeteer';
4853 * const slow3G = PredefinedNetworkConditions['Slow 3G'];
4854 *
4855 * (async () => {
4856 * const browser = await puppeteer.launch();
4857 * const page = await browser.newPage();
4858 * await page.emulateNetworkConditions(slow3G);
4859 * await page.goto('https://www.google.com');
4860 * // other actions...
4861 * await browser.close();
4862 * })();
4863 * ```
4864 *
4865 * @param networkConditions - Passing `null` disables network condition
4866 * emulation.
4867 */
4868 abstract emulateNetworkConditions(networkConditions: NetworkConditions | null): Promise<void>;
4869 /**
4870 * This setting will change the default maximum navigation time for the
4871 * following methods and related shortcuts:
4872 *
4873 * - {@link Page.goBack | page.goBack(options)}
4874 *
4875 * - {@link Page.goForward | page.goForward(options)}
4876 *
4877 * - {@link Page.goto | page.goto(url,options)}
4878 *
4879 * - {@link Page.reload | page.reload(options)}
4880 *
4881 * - {@link Page.setContent | page.setContent(html,options)}
4882 *
4883 * - {@link Page.waitForNavigation | page.waitForNavigation(options)}
4884 * @param timeout - Maximum navigation time in milliseconds.
4885 */
4886 abstract setDefaultNavigationTimeout(timeout: number): void;
4887 /**
4888 * @param timeout - Maximum time in milliseconds.
4889 */
4890 abstract setDefaultTimeout(timeout: number): void;
4891 /**
4892 * Maximum time in milliseconds.
4893 */
4894 abstract getDefaultTimeout(): number;
4895 /**
4896 * Creates a locator for the provided selector. See {@link Locator} for
4897 * details and supported actions.
4898 *
4899 * @param selector -
4900 * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
4901 * to query the page for.
4902 * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
4903 * can be passed as-is and a
4904 * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
4905 * allows quering by
4906 * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
4907 * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
4908 * and
4909 * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
4910 * and
4911 * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
4912 * Alternatively, you can specify the selector type using a
4913 * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
4914 */
4915 locator<Selector extends string>(selector: Selector): Locator<NodeFor<Selector>>;
4916 /**
4917 * Creates a locator for the provided function. See {@link Locator} for
4918 * details and supported actions.
4919 *
4920 * @param selector -
4921 * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
4922 * to query the page for.
4923 * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
4924 * can be passed as-is and a
4925 * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
4926 * allows quering by
4927 * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
4928 * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
4929 * and
4930 * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
4931 * and
4932 * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
4933 * Alternatively, you can specify the selector type using a
4934 * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
4935 */
4936 locator<Ret>(func: () => Awaitable<Ret>): Locator<Ret>;
4937 /* Excluded from this release type: locatorRace */
4938 /**
4939 * Finds the first element that matches the selector. If no element matches
4940 * the selector, the return value resolves to `null`.
4941 *
4942 * @param selector -
4943 * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
4944 * to query the page for.
4945 * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
4946 * can be passed as-is and a
4947 * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
4948 * allows quering by
4949 * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
4950 * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
4951 * and
4952 * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
4953 * and
4954 * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
4955 * Alternatively, you can specify the selector type using a
4956 * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
4957 *
4958 * @remarks
4959 *
4960 * Shortcut for {@link Frame.$ | Page.mainFrame().$(selector) }.
4961 */
4962 $<Selector extends string>(selector: Selector): Promise<ElementHandle<NodeFor<Selector>> | null>;
4963 /**
4964 * Finds elements on the page that match the selector. If no elements
4965 * match the selector, the return value resolves to `[]`.
4966 *
4967 * @param selector -
4968 * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
4969 * to query the page for.
4970 * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
4971 * can be passed as-is and a
4972 * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
4973 * allows quering by
4974 * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
4975 * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
4976 * and
4977 * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
4978 * and
4979 * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
4980 * Alternatively, you can specify the selector type using a
4981 * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
4982 *
4983 * @remarks
4984 *
4985 * Shortcut for {@link Frame.$$ | Page.mainFrame().$$(selector) }.
4986 */
4987 $$<Selector extends string>(selector: Selector, options?: QueryOptions): Promise<Array<ElementHandle<NodeFor<Selector>>>>;
4988 /**
4989 * @remarks
4990 *
4991 * The only difference between {@link Page.evaluate | page.evaluate} and
4992 * `page.evaluateHandle` is that `evaluateHandle` will return the value
4993 * wrapped in an in-page object.
4994 *
4995 * If the function passed to `page.evaluateHandle` returns a Promise, the
4996 * function will wait for the promise to resolve and return its value.
4997 *
4998 * You can pass a string instead of a function (although functions are
4999 * recommended as they are easier to debug and use with TypeScript):
5000 *
5001 * @example
5002 *
5003 * ```ts
5004 * const aHandle = await page.evaluateHandle('document');
5005 * ```
5006 *
5007 * @example
5008 * {@link JSHandle} instances can be passed as arguments to the `pageFunction`:
5009 *
5010 * ```ts
5011 * const aHandle = await page.evaluateHandle(() => document.body);
5012 * const resultHandle = await page.evaluateHandle(
5013 * body => body.innerHTML,
5014 * aHandle
5015 * );
5016 * console.log(await resultHandle.jsonValue());
5017 * await resultHandle.dispose();
5018 * ```
5019 *
5020 * Most of the time this function returns a {@link JSHandle},
5021 * but if `pageFunction` returns a reference to an element,
5022 * you instead get an {@link ElementHandle} back:
5023 *
5024 * @example
5025 *
5026 * ```ts
5027 * const button = await page.evaluateHandle(() =>
5028 * document.querySelector('button')
5029 * );
5030 * // can call `click` because `button` is an `ElementHandle`
5031 * await button.click();
5032 * ```
5033 *
5034 * The TypeScript definitions assume that `evaluateHandle` returns
5035 * a `JSHandle`, but if you know it's going to return an
5036 * `ElementHandle`, pass it as the generic argument:
5037 *
5038 * ```ts
5039 * const button = await page.evaluateHandle<ElementHandle>(...);
5040 * ```
5041 *
5042 * @param pageFunction - a function that is run within the page
5043 * @param args - arguments to be passed to the pageFunction
5044 */
5045 evaluateHandle<Params extends unknown[], Func extends EvaluateFunc<Params> = EvaluateFunc<Params>>(pageFunction: Func | string, ...args: Params): Promise<HandleFor<Awaited<ReturnType<Func>>>>;
5046 /**
5047 * This method iterates the JavaScript heap and finds all objects with the
5048 * given prototype.
5049 *
5050 * @example
5051 *
5052 * ```ts
5053 * // Create a Map object
5054 * await page.evaluate(() => (window.map = new Map()));
5055 * // Get a handle to the Map object prototype
5056 * const mapPrototype = await page.evaluateHandle(() => Map.prototype);
5057 * // Query all map instances into an array
5058 * const mapInstances = await page.queryObjects(mapPrototype);
5059 * // Count amount of map objects in heap
5060 * const count = await page.evaluate(maps => maps.length, mapInstances);
5061 * await mapInstances.dispose();
5062 * await mapPrototype.dispose();
5063 * ```
5064 *
5065 * @param prototypeHandle - a handle to the object prototype.
5066 * @returns Promise which resolves to a handle to an array of objects with
5067 * this prototype.
5068 */
5069 abstract queryObjects<Prototype>(prototypeHandle: JSHandle<Prototype>): Promise<JSHandle<Prototype[]>>;
5070 /**
5071 * This method finds the first element within the page that matches the selector
5072 * and passes the result as the first argument to the `pageFunction`.
5073 *
5074 * @remarks
5075 *
5076 * If no element is found matching `selector`, the method will throw an error.
5077 *
5078 * If `pageFunction` returns a promise `$eval` will wait for the promise to
5079 * resolve and then return its value.
5080 *
5081 * @example
5082 *
5083 * ```ts
5084 * const searchValue = await page.$eval('#search', el => el.value);
5085 * const preloadHref = await page.$eval('link[rel=preload]', el => el.href);
5086 * const html = await page.$eval('.main-container', el => el.outerHTML);
5087 * ```
5088 *
5089 * If you are using TypeScript, you may have to provide an explicit type to the
5090 * first argument of the `pageFunction`.
5091 * By default it is typed as `Element`, but you may need to provide a more
5092 * specific sub-type:
5093 *
5094 * @example
5095 *
5096 * ```ts
5097 * // if you don't provide HTMLInputElement here, TS will error
5098 * // as `value` is not on `Element`
5099 * const searchValue = await page.$eval(
5100 * '#search',
5101 * (el: HTMLInputElement) => el.value
5102 * );
5103 * ```
5104 *
5105 * The compiler should be able to infer the return type
5106 * from the `pageFunction` you provide. If it is unable to, you can use the generic
5107 * type to tell the compiler what return type you expect from `$eval`:
5108 *
5109 * @example
5110 *
5111 * ```ts
5112 * // The compiler can infer the return type in this case, but if it can't
5113 * // or if you want to be more explicit, provide it as the generic type.
5114 * const searchValue = await page.$eval<string>(
5115 * '#search',
5116 * (el: HTMLInputElement) => el.value
5117 * );
5118 * ```
5119 *
5120 * @param selector -
5121 * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
5122 * to query the page for.
5123 * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
5124 * can be passed as-is and a
5125 * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
5126 * allows quering by
5127 * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
5128 * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
5129 * and
5130 * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
5131 * and
5132 * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
5133 * Alternatively, you can specify the selector type using a
5134 * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
5135 * @param pageFunction - the function to be evaluated in the page context.
5136 * Will be passed the result of the element matching the selector as its
5137 * first argument.
5138 * @param args - any additional arguments to pass through to `pageFunction`.
5139 *
5140 * @returns The result of calling `pageFunction`. If it returns an element it
5141 * is wrapped in an {@link ElementHandle}, else the raw value itself is
5142 * returned.
5143 */
5144 $eval<Selector extends string, Params extends unknown[], Func extends EvaluateFuncWith<NodeFor<Selector>, Params> = EvaluateFuncWith<NodeFor<Selector>, Params>>(selector: Selector, pageFunction: Func | string, ...args: Params): Promise<Awaited<ReturnType<Func>>>;
5145 /**
5146 * This method returns all elements matching the selector and passes the
5147 * resulting array as the first argument to the `pageFunction`.
5148 *
5149 * @remarks
5150 * If `pageFunction` returns a promise `$$eval` will wait for the promise to
5151 * resolve and then return its value.
5152 *
5153 * @example
5154 *
5155 * ```ts
5156 * // get the amount of divs on the page
5157 * const divCount = await page.$$eval('div', divs => divs.length);
5158 *
5159 * // get the text content of all the `.options` elements:
5160 * const options = await page.$$eval('div > span.options', options => {
5161 * return options.map(option => option.textContent);
5162 * });
5163 * ```
5164 *
5165 * If you are using TypeScript, you may have to provide an explicit type to the
5166 * first argument of the `pageFunction`.
5167 * By default it is typed as `Element[]`, but you may need to provide a more
5168 * specific sub-type:
5169 *
5170 * @example
5171 *
5172 * ```ts
5173 * await page.$$eval('input', elements => {
5174 * return elements.map(e => e.value);
5175 * });
5176 * ```
5177 *
5178 * The compiler should be able to infer the return type
5179 * from the `pageFunction` you provide. If it is unable to, you can use the generic
5180 * type to tell the compiler what return type you expect from `$$eval`:
5181 *
5182 * @example
5183 *
5184 * ```ts
5185 * const allInputValues = await page.$$eval('input', elements =>
5186 * elements.map(e => e.textContent)
5187 * );
5188 * ```
5189 *
5190 * @param selector -
5191 * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
5192 * to query the page for.
5193 * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
5194 * can be passed as-is and a
5195 * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
5196 * allows quering by
5197 * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
5198 * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
5199 * and
5200 * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
5201 * and
5202 * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
5203 * Alternatively, you can specify the selector type using a
5204 * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
5205 * @param pageFunction - the function to be evaluated in the page context.
5206 * Will be passed an array of matching elements as its first argument.
5207 * @param args - any additional arguments to pass through to `pageFunction`.
5208 *
5209 * @returns The result of calling `pageFunction`. If it returns an element it
5210 * is wrapped in an {@link ElementHandle}, else the raw value itself is
5211 * returned.
5212 */
5213 $$eval<Selector extends string, Params extends unknown[], Func extends EvaluateFuncWith<Array<NodeFor<Selector>>, Params> = EvaluateFuncWith<Array<NodeFor<Selector>>, Params>>(selector: Selector, pageFunction: Func | string, ...args: Params): Promise<Awaited<ReturnType<Func>>>;
5214 /**
5215 * If no URLs are specified, this method returns cookies for the current page
5216 * URL. If URLs are specified, only cookies for those URLs are returned.
5217 */
5218 abstract cookies(...urls: string[]): Promise<Cookie[]>;
5219 abstract deleteCookie(...cookies: DeleteCookiesRequest[]): Promise<void>;
5220 /**
5221 * @example
5222 *
5223 * ```ts
5224 * await page.setCookie(cookieObject1, cookieObject2);
5225 * ```
5226 */
5227 abstract setCookie(...cookies: CookieParam[]): Promise<void>;
5228 /**
5229 * Adds a `<script>` tag into the page with the desired URL or content.
5230 *
5231 * @remarks
5232 * Shortcut for
5233 * {@link Frame.addScriptTag | page.mainFrame().addScriptTag(options)}.
5234 *
5235 * @param options - Options for the script.
5236 * @returns An {@link ElementHandle | element handle} to the injected
5237 * `<script>` element.
5238 */
5239 addScriptTag(options: FrameAddScriptTagOptions): Promise<ElementHandle<HTMLScriptElement>>;
5240 /**
5241 * Adds a `<link rel="stylesheet">` tag into the page with the desired URL or
5242 * a `<style type="text/css">` tag with the content.
5243 *
5244 * Shortcut for
5245 * {@link Frame.(addStyleTag:2) | page.mainFrame().addStyleTag(options)}.
5246 *
5247 * @returns An {@link ElementHandle | element handle} to the injected `<link>`
5248 * or `<style>` element.
5249 */
5250 addStyleTag(options: Omit<FrameAddStyleTagOptions, 'url'>): Promise<ElementHandle<HTMLStyleElement>>;
5251 addStyleTag(options: FrameAddStyleTagOptions): Promise<ElementHandle<HTMLLinkElement>>;
5252 /**
5253 * The method adds a function called `name` on the page's `window` object.
5254 * When called, the function executes `puppeteerFunction` in node.js and
5255 * returns a `Promise` which resolves to the return value of
5256 * `puppeteerFunction`.
5257 *
5258 * If the puppeteerFunction returns a `Promise`, it will be awaited.
5259 *
5260 * :::note
5261 *
5262 * Functions installed via `page.exposeFunction` survive navigations.
5263 *
5264 * :::
5265 *
5266 * @example
5267 * An example of adding an `md5` function into the page:
5268 *
5269 * ```ts
5270 * import puppeteer from 'puppeteer';
5271 * import crypto from 'crypto';
5272 *
5273 * (async () => {
5274 * const browser = await puppeteer.launch();
5275 * const page = await browser.newPage();
5276 * page.on('console', msg => console.log(msg.text()));
5277 * await page.exposeFunction('md5', text =>
5278 * crypto.createHash('md5').update(text).digest('hex')
5279 * );
5280 * await page.evaluate(async () => {
5281 * // use window.md5 to compute hashes
5282 * const myString = 'PUPPETEER';
5283 * const myHash = await window.md5(myString);
5284 * console.log(`md5 of ${myString} is ${myHash}`);
5285 * });
5286 * await browser.close();
5287 * })();
5288 * ```
5289 *
5290 * @example
5291 * An example of adding a `window.readfile` function into the page:
5292 *
5293 * ```ts
5294 * import puppeteer from 'puppeteer';
5295 * import fs from 'fs';
5296 *
5297 * (async () => {
5298 * const browser = await puppeteer.launch();
5299 * const page = await browser.newPage();
5300 * page.on('console', msg => console.log(msg.text()));
5301 * await page.exposeFunction('readfile', async filePath => {
5302 * return new Promise((resolve, reject) => {
5303 * fs.readFile(filePath, 'utf8', (err, text) => {
5304 * if (err) reject(err);
5305 * else resolve(text);
5306 * });
5307 * });
5308 * });
5309 * await page.evaluate(async () => {
5310 * // use window.readfile to read contents of a file
5311 * const content = await window.readfile('/etc/hosts');
5312 * console.log(content);
5313 * });
5314 * await browser.close();
5315 * })();
5316 * ```
5317 *
5318 * @param name - Name of the function on the window object
5319 * @param pptrFunction - Callback function which will be called in Puppeteer's
5320 * context.
5321 */
5322 abstract exposeFunction(name: string, pptrFunction: Function | {
5323 default: Function;
5324 }): Promise<void>;
5325 /**
5326 * The method removes a previously added function via ${@link Page.exposeFunction}
5327 * called `name` from the page's `window` object.
5328 */
5329 abstract removeExposedFunction(name: string): Promise<void>;
5330 /**
5331 * Provide credentials for `HTTP authentication`.
5332 *
5333 * :::note
5334 *
5335 * Request interception will be turned on behind the scenes to
5336 * implement authentication. This might affect performance.
5337 *
5338 * :::
5339 *
5340 * @remarks
5341 * To disable authentication, pass `null`.
5342 */
5343 abstract authenticate(credentials: Credentials | null): Promise<void>;
5344 /**
5345 * The extra HTTP headers will be sent with every request the page initiates.
5346 *
5347 * :::tip
5348 *
5349 * All HTTP header names are lowercased. (HTTP headers are
5350 * case-insensitive, so this shouldn’t impact your server code.)
5351 *
5352 * :::
5353 *
5354 * :::note
5355 *
5356 * page.setExtraHTTPHeaders does not guarantee the order of headers in
5357 * the outgoing requests.
5358 *
5359 * :::
5360 *
5361 * @param headers - An object containing additional HTTP headers to be sent
5362 * with every request. All header values must be strings.
5363 */
5364 abstract setExtraHTTPHeaders(headers: Record<string, string>): Promise<void>;
5365 /**
5366 * @param userAgent - Specific user agent to use in this page
5367 * @param userAgentData - Specific user agent client hint data to use in this
5368 * page
5369 * @returns Promise which resolves when the user agent is set.
5370 */
5371 abstract setUserAgent(userAgent: string, userAgentMetadata?: Protocol.Emulation.UserAgentMetadata): Promise<void>;
5372 /**
5373 * Object containing metrics as key/value pairs.
5374 *
5375 * @returns
5376 *
5377 * - `Timestamp` : The timestamp when the metrics sample was taken.
5378 *
5379 * - `Documents` : Number of documents in the page.
5380 *
5381 * - `Frames` : Number of frames in the page.
5382 *
5383 * - `JSEventListeners` : Number of events in the page.
5384 *
5385 * - `Nodes` : Number of DOM nodes in the page.
5386 *
5387 * - `LayoutCount` : Total number of full or partial page layout.
5388 *
5389 * - `RecalcStyleCount` : Total number of page style recalculations.
5390 *
5391 * - `LayoutDuration` : Combined durations of all page layouts.
5392 *
5393 * - `RecalcStyleDuration` : Combined duration of all page style
5394 * recalculations.
5395 *
5396 * - `ScriptDuration` : Combined duration of JavaScript execution.
5397 *
5398 * - `TaskDuration` : Combined duration of all tasks performed by the browser.
5399 *
5400 * - `JSHeapUsedSize` : Used JavaScript heap size.
5401 *
5402 * - `JSHeapTotalSize` : Total JavaScript heap size.
5403 *
5404 * @remarks
5405 * All timestamps are in monotonic time: monotonically increasing time
5406 * in seconds since an arbitrary point in the past.
5407 */
5408 abstract metrics(): Promise<Metrics>;
5409 /**
5410 * The page's URL.
5411 *
5412 * @remarks
5413 *
5414 * Shortcut for {@link Frame.url | page.mainFrame().url()}.
5415 */
5416 url(): string;
5417 /**
5418 * The full HTML contents of the page, including the DOCTYPE.
5419 */
5420 content(): Promise<string>;
5421 /**
5422 * Set the content of the page.
5423 *
5424 * @param html - HTML markup to assign to the page.
5425 * @param options - Parameters that has some properties.
5426 */
5427 setContent(html: string, options?: WaitForOptions): Promise<void>;
5428 /**
5429 * {@inheritDoc Frame.goto}
5430 */
5431 goto(url: string, options?: GoToOptions): Promise<HTTPResponse | null>;
5432 /**
5433 * Reloads the page.
5434 *
5435 * @param options - Options to configure waiting behavior.
5436 * @returns A promise which resolves to the main resource response. In case of
5437 * multiple redirects, the navigation will resolve with the response of the
5438 * last redirect.
5439 */
5440 abstract reload(options?: WaitForOptions): Promise<HTTPResponse | null>;
5441 /**
5442 * Waits for the page to navigate to a new URL or to reload. It is useful when
5443 * you run code that will indirectly cause the page to navigate.
5444 *
5445 * @example
5446 *
5447 * ```ts
5448 * const [response] = await Promise.all([
5449 * page.waitForNavigation(), // The promise resolves after navigation has finished
5450 * page.click('a.my-link'), // Clicking the link will indirectly cause a navigation
5451 * ]);
5452 * ```
5453 *
5454 * @remarks
5455 *
5456 * Usage of the
5457 * {@link https://developer.mozilla.org/en-US/docs/Web/API/History_API | History API}
5458 * to change the URL is considered a navigation.
5459 *
5460 * @param options - Navigation parameters which might have the following
5461 * properties:
5462 * @returns A `Promise` which resolves to the main resource response.
5463 *
5464 * - In case of multiple redirects, the navigation will resolve with the
5465 * response of the last redirect.
5466 * - In case of navigation to a different anchor or navigation due to History
5467 * API usage, the navigation will resolve with `null`.
5468 */
5469 waitForNavigation(options?: WaitForOptions): Promise<HTTPResponse | null>;
5470 /**
5471 * @param urlOrPredicate - A URL or predicate to wait for
5472 * @param options - Optional waiting parameters
5473 * @returns Promise which resolves to the matched request
5474 * @example
5475 *
5476 * ```ts
5477 * const firstRequest = await page.waitForRequest(
5478 * 'https://example.com/resource'
5479 * );
5480 * const finalRequest = await page.waitForRequest(
5481 * request => request.url() === 'https://example.com'
5482 * );
5483 * return finalRequest.response()?.ok();
5484 * ```
5485 *
5486 * @remarks
5487 * Optional Waiting Parameters have:
5488 *
5489 * - `timeout`: Maximum wait time in milliseconds, defaults to `30` seconds, pass
5490 * `0` to disable the timeout. The default value can be changed by using the
5491 * {@link Page.setDefaultTimeout} method.
5492 */
5493 waitForRequest(urlOrPredicate: string | AwaitablePredicate<HTTPRequest>, options?: WaitTimeoutOptions): Promise<HTTPRequest>;
5494 /**
5495 * @param urlOrPredicate - A URL or predicate to wait for.
5496 * @param options - Optional waiting parameters
5497 * @returns Promise which resolves to the matched response.
5498 * @example
5499 *
5500 * ```ts
5501 * const firstResponse = await page.waitForResponse(
5502 * 'https://example.com/resource'
5503 * );
5504 * const finalResponse = await page.waitForResponse(
5505 * response =>
5506 * response.url() === 'https://example.com' && response.status() === 200
5507 * );
5508 * const finalResponse = await page.waitForResponse(async response => {
5509 * return (await response.text()).includes('<html>');
5510 * });
5511 * return finalResponse.ok();
5512 * ```
5513 *
5514 * @remarks
5515 * Optional Parameter have:
5516 *
5517 * - `timeout`: Maximum wait time in milliseconds, defaults to `30` seconds,
5518 * pass `0` to disable the timeout. The default value can be changed by using
5519 * the {@link Page.setDefaultTimeout} method.
5520 */
5521 waitForResponse(urlOrPredicate: string | AwaitablePredicate<HTTPResponse>, options?: WaitTimeoutOptions): Promise<HTTPResponse>;
5522 /**
5523 * Waits for the network to be idle.
5524 *
5525 * @param options - Options to configure waiting behavior.
5526 * @returns A promise which resolves once the network is idle.
5527 */
5528 waitForNetworkIdle(options?: WaitForNetworkIdleOptions): Promise<void>;
5529 /* Excluded from this release type: waitForNetworkIdle$ */
5530 /**
5531 * Waits for a frame matching the given conditions to appear.
5532 *
5533 * @example
5534 *
5535 * ```ts
5536 * const frame = await page.waitForFrame(async frame => {
5537 * return frame.name() === 'Test';
5538 * });
5539 * ```
5540 */
5541 waitForFrame(urlOrPredicate: string | ((frame: Frame) => Awaitable<boolean>), options?: WaitTimeoutOptions): Promise<Frame>;
5542 /**
5543 * This method navigate to the previous page in history.
5544 * @param options - Navigation parameters
5545 * @returns Promise which resolves to the main resource response. In case of
5546 * multiple redirects, the navigation will resolve with the response of the
5547 * last redirect. If can not go back, resolves to `null`.
5548 */
5549 abstract goBack(options?: WaitForOptions): Promise<HTTPResponse | null>;
5550 /**
5551 * This method navigate to the next page in history.
5552 * @param options - Navigation Parameter
5553 * @returns Promise which resolves to the main resource response. In case of
5554 * multiple redirects, the navigation will resolve with the response of the
5555 * last redirect. If can not go forward, resolves to `null`.
5556 */
5557 abstract goForward(options?: WaitForOptions): Promise<HTTPResponse | null>;
5558 /**
5559 * Brings page to front (activates tab).
5560 */
5561 abstract bringToFront(): Promise<void>;
5562 /**
5563 * Emulates a given device's metrics and user agent.
5564 *
5565 * To aid emulation, Puppeteer provides a list of known devices that can be
5566 * via {@link KnownDevices}.
5567 *
5568 * @remarks
5569 * This method is a shortcut for calling two methods:
5570 * {@link Page.setUserAgent} and {@link Page.setViewport}.
5571 *
5572 * This method will resize the page. A lot of websites don't expect phones to
5573 * change size, so you should emulate before navigating to the page.
5574 *
5575 * @example
5576 *
5577 * ```ts
5578 * import {KnownDevices} from 'puppeteer';
5579 * const iPhone = KnownDevices['iPhone 15 Pro'];
5580 *
5581 * (async () => {
5582 * const browser = await puppeteer.launch();
5583 * const page = await browser.newPage();
5584 * await page.emulate(iPhone);
5585 * await page.goto('https://www.google.com');
5586 * // other actions...
5587 * await browser.close();
5588 * })();
5589 * ```
5590 */
5591 emulate(device: Device): Promise<void>;
5592 /**
5593 * @param enabled - Whether or not to enable JavaScript on the page.
5594 * @remarks
5595 * NOTE: changing this value won't affect scripts that have already been run.
5596 * It will take full effect on the next navigation.
5597 */
5598 abstract setJavaScriptEnabled(enabled: boolean): Promise<void>;
5599 /**
5600 * Toggles bypassing page's Content-Security-Policy.
5601 * @param enabled - sets bypassing of page's Content-Security-Policy.
5602 * @remarks
5603 * NOTE: CSP bypassing happens at the moment of CSP initialization rather than
5604 * evaluation. Usually, this means that `page.setBypassCSP` should be called
5605 * before navigating to the domain.
5606 */
5607 abstract setBypassCSP(enabled: boolean): Promise<void>;
5608 /**
5609 * @param type - Changes the CSS media type of the page. The only allowed
5610 * values are `screen`, `print` and `null`. Passing `null` disables CSS media
5611 * emulation.
5612 * @example
5613 *
5614 * ```ts
5615 * await page.evaluate(() => matchMedia('screen').matches);
5616 * // → true
5617 * await page.evaluate(() => matchMedia('print').matches);
5618 * // → false
5619 *
5620 * await page.emulateMediaType('print');
5621 * await page.evaluate(() => matchMedia('screen').matches);
5622 * // → false
5623 * await page.evaluate(() => matchMedia('print').matches);
5624 * // → true
5625 *
5626 * await page.emulateMediaType(null);
5627 * await page.evaluate(() => matchMedia('screen').matches);
5628 * // → true
5629 * await page.evaluate(() => matchMedia('print').matches);
5630 * // → false
5631 * ```
5632 */
5633 abstract emulateMediaType(type?: string): Promise<void>;
5634 /**
5635 * Enables CPU throttling to emulate slow CPUs.
5636 * @param factor - slowdown factor (1 is no throttle, 2 is 2x slowdown, etc).
5637 */
5638 abstract emulateCPUThrottling(factor: number | null): Promise<void>;
5639 /**
5640 * @param features - `<?Array<Object>>` Given an array of media feature
5641 * objects, emulates CSS media features on the page. Each media feature object
5642 * must have the following properties:
5643 * @example
5644 *
5645 * ```ts
5646 * await page.emulateMediaFeatures([
5647 * {name: 'prefers-color-scheme', value: 'dark'},
5648 * ]);
5649 * await page.evaluate(
5650 * () => matchMedia('(prefers-color-scheme: dark)').matches
5651 * );
5652 * // → true
5653 * await page.evaluate(
5654 * () => matchMedia('(prefers-color-scheme: light)').matches
5655 * );
5656 * // → false
5657 *
5658 * await page.emulateMediaFeatures([
5659 * {name: 'prefers-reduced-motion', value: 'reduce'},
5660 * ]);
5661 * await page.evaluate(
5662 * () => matchMedia('(prefers-reduced-motion: reduce)').matches
5663 * );
5664 * // → true
5665 * await page.evaluate(
5666 * () => matchMedia('(prefers-reduced-motion: no-preference)').matches
5667 * );
5668 * // → false
5669 *
5670 * await page.emulateMediaFeatures([
5671 * {name: 'prefers-color-scheme', value: 'dark'},
5672 * {name: 'prefers-reduced-motion', value: 'reduce'},
5673 * ]);
5674 * await page.evaluate(
5675 * () => matchMedia('(prefers-color-scheme: dark)').matches
5676 * );
5677 * // → true
5678 * await page.evaluate(
5679 * () => matchMedia('(prefers-color-scheme: light)').matches
5680 * );
5681 * // → false
5682 * await page.evaluate(
5683 * () => matchMedia('(prefers-reduced-motion: reduce)').matches
5684 * );
5685 * // → true
5686 * await page.evaluate(
5687 * () => matchMedia('(prefers-reduced-motion: no-preference)').matches
5688 * );
5689 * // → false
5690 *
5691 * await page.emulateMediaFeatures([{name: 'color-gamut', value: 'p3'}]);
5692 * await page.evaluate(() => matchMedia('(color-gamut: srgb)').matches);
5693 * // → true
5694 * await page.evaluate(() => matchMedia('(color-gamut: p3)').matches);
5695 * // → true
5696 * await page.evaluate(() => matchMedia('(color-gamut: rec2020)').matches);
5697 * // → false
5698 * ```
5699 */
5700 abstract emulateMediaFeatures(features?: MediaFeature[]): Promise<void>;
5701 /**
5702 * @param timezoneId - Changes the timezone of the page. See
5703 * {@link https://source.chromium.org/chromium/chromium/deps/icu.git/+/faee8bc70570192d82d2978a71e2a615788597d1:source/data/misc/metaZones.txt | ICU’s metaZones.txt}
5704 * for a list of supported timezone IDs. Passing
5705 * `null` disables timezone emulation.
5706 */
5707 abstract emulateTimezone(timezoneId?: string): Promise<void>;
5708 /**
5709 * Emulates the idle state.
5710 * If no arguments set, clears idle state emulation.
5711 *
5712 * @example
5713 *
5714 * ```ts
5715 * // set idle emulation
5716 * await page.emulateIdleState({isUserActive: true, isScreenUnlocked: false});
5717 *
5718 * // do some checks here
5719 * ...
5720 *
5721 * // clear idle emulation
5722 * await page.emulateIdleState();
5723 * ```
5724 *
5725 * @param overrides - Mock idle state. If not set, clears idle overrides
5726 */
5727 abstract emulateIdleState(overrides?: {
5728 isUserActive: boolean;
5729 isScreenUnlocked: boolean;
5730 }): Promise<void>;
5731 /**
5732 * Simulates the given vision deficiency on the page.
5733 *
5734 * @example
5735 *
5736 * ```ts
5737 * import puppeteer from 'puppeteer';
5738 *
5739 * (async () => {
5740 * const browser = await puppeteer.launch();
5741 * const page = await browser.newPage();
5742 * await page.goto('https://v8.dev/blog/10-years');
5743 *
5744 * await page.emulateVisionDeficiency('achromatopsia');
5745 * await page.screenshot({path: 'achromatopsia.png'});
5746 *
5747 * await page.emulateVisionDeficiency('deuteranopia');
5748 * await page.screenshot({path: 'deuteranopia.png'});
5749 *
5750 * await page.emulateVisionDeficiency('blurredVision');
5751 * await page.screenshot({path: 'blurred-vision.png'});
5752 *
5753 * await browser.close();
5754 * })();
5755 * ```
5756 *
5757 * @param type - the type of deficiency to simulate, or `'none'` to reset.
5758 */
5759 abstract emulateVisionDeficiency(type?: Protocol.Emulation.SetEmulatedVisionDeficiencyRequest['type']): Promise<void>;
5760 /**
5761 * `page.setViewport` will resize the page. A lot of websites don't expect
5762 * phones to change size, so you should set the viewport before navigating to
5763 * the page.
5764 *
5765 * In the case of multiple pages in a single browser, each page can have its
5766 * own viewport size. Setting the viewport to `null` resets the viewport to
5767 * its default value.
5768 *
5769 * @example
5770 *
5771 * ```ts
5772 * const page = await browser.newPage();
5773 * await page.setViewport({
5774 * width: 640,
5775 * height: 480,
5776 * deviceScaleFactor: 1,
5777 * });
5778 * await page.goto('https://example.com');
5779 * ```
5780 *
5781 * @param viewport -
5782 * @remarks
5783 * NOTE: in certain cases, setting viewport will reload the page in order to
5784 * set the isMobile or hasTouch properties.
5785 */
5786 abstract setViewport(viewport: Viewport | null): Promise<void>;
5787 /**
5788 * Returns the current page viewport settings without checking the actual page
5789 * viewport.
5790 *
5791 * This is either the viewport set with the previous {@link Page.setViewport}
5792 * call or the default viewport set via
5793 * {@link BrowserConnectOptions.defaultViewport |
5794 * BrowserConnectOptions.defaultViewport}.
5795 */
5796 abstract viewport(): Viewport | null;
5797 /**
5798 * Evaluates a function in the page's context and returns the result.
5799 *
5800 * If the function passed to `page.evaluate` returns a Promise, the
5801 * function will wait for the promise to resolve and return its value.
5802 *
5803 * @example
5804 *
5805 * ```ts
5806 * const result = await frame.evaluate(() => {
5807 * return Promise.resolve(8 * 7);
5808 * });
5809 * console.log(result); // prints "56"
5810 * ```
5811 *
5812 * You can pass a string instead of a function (although functions are
5813 * recommended as they are easier to debug and use with TypeScript):
5814 *
5815 * @example
5816 *
5817 * ```ts
5818 * const aHandle = await page.evaluate('1 + 2');
5819 * ```
5820 *
5821 * To get the best TypeScript experience, you should pass in as the
5822 * generic the type of `pageFunction`:
5823 *
5824 * ```ts
5825 * const aHandle = await page.evaluate(() => 2);
5826 * ```
5827 *
5828 * @example
5829 *
5830 * {@link ElementHandle} instances (including {@link JSHandle}s) can be passed
5831 * as arguments to the `pageFunction`:
5832 *
5833 * ```ts
5834 * const bodyHandle = await page.$('body');
5835 * const html = await page.evaluate(body => body.innerHTML, bodyHandle);
5836 * await bodyHandle.dispose();
5837 * ```
5838 *
5839 * @param pageFunction - a function that is run within the page
5840 * @param args - arguments to be passed to the pageFunction
5841 *
5842 * @returns the return value of `pageFunction`.
5843 */
5844 evaluate<Params extends unknown[], Func extends EvaluateFunc<Params> = EvaluateFunc<Params>>(pageFunction: Func | string, ...args: Params): Promise<Awaited<ReturnType<Func>>>;
5845 /**
5846 * Adds a function which would be invoked in one of the following scenarios:
5847 *
5848 * - whenever the page is navigated
5849 *
5850 * - whenever the child frame is attached or navigated. In this case, the
5851 * function is invoked in the context of the newly attached frame.
5852 *
5853 * The function is invoked after the document was created but before any of
5854 * its scripts were run. This is useful to amend the JavaScript environment,
5855 * e.g. to seed `Math.random`.
5856 * @param pageFunction - Function to be evaluated in browser context
5857 * @param args - Arguments to pass to `pageFunction`
5858 * @example
5859 * An example of overriding the navigator.languages property before the page loads:
5860 *
5861 * ```ts
5862 * // preload.js
5863 *
5864 * // overwrite the `languages` property to use a custom getter
5865 * Object.defineProperty(navigator, 'languages', {
5866 * get: function () {
5867 * return ['en-US', 'en', 'bn'];
5868 * },
5869 * });
5870 *
5871 * // In your puppeteer script, assuming the preload.js file is
5872 * // in same folder of our script.
5873 * const preloadFile = fs.readFileSync('./preload.js', 'utf8');
5874 * await page.evaluateOnNewDocument(preloadFile);
5875 * ```
5876 */
5877 abstract evaluateOnNewDocument<Params extends unknown[], Func extends (...args: Params) => unknown = (...args: Params) => unknown>(pageFunction: Func | string, ...args: Params): Promise<NewDocumentScriptEvaluation>;
5878 /**
5879 * Removes script that injected into page by Page.evaluateOnNewDocument.
5880 *
5881 * @param identifier - script identifier
5882 */
5883 abstract removeScriptToEvaluateOnNewDocument(identifier: string): Promise<void>;
5884 /**
5885 * Toggles ignoring cache for each request based on the enabled state. By
5886 * default, caching is enabled.
5887 * @param enabled - sets the `enabled` state of cache
5888 * @defaultValue `true`
5889 */
5890 abstract setCacheEnabled(enabled?: boolean): Promise<void>;
5891 /* Excluded from this release type: _maybeWriteTypedArrayToFile */
5892 /**
5893 * Captures a screencast of this {@link Page | page}.
5894 *
5895 * @example
5896 * Recording a {@link Page | page}:
5897 *
5898 * ```
5899 * import puppeteer from 'puppeteer';
5900 *
5901 * // Launch a browser
5902 * const browser = await puppeteer.launch();
5903 *
5904 * // Create a new page
5905 * const page = await browser.newPage();
5906 *
5907 * // Go to your site.
5908 * await page.goto("https://www.example.com");
5909 *
5910 * // Start recording.
5911 * const recorder = await page.screencast({path: 'recording.webm'});
5912 *
5913 * // Do something.
5914 *
5915 * // Stop recording.
5916 * await recorder.stop();
5917 *
5918 * browser.close();
5919 * ```
5920 *
5921 * @param options - Configures screencast behavior.
5922 *
5923 * @experimental
5924 *
5925 * @remarks
5926 *
5927 * All recordings will be {@link https://www.webmproject.org/ | WebM} format using
5928 * the {@link https://www.webmproject.org/vp9/ | VP9} video codec. The FPS is 30.
5929 *
5930 * You must have {@link https://ffmpeg.org/ | ffmpeg} installed on your system.
5931 */
5932 screencast(options?: Readonly<ScreencastOptions>): Promise<ScreenRecorder>;
5933 /* Excluded from this release type: _startScreencast */
5934 /* Excluded from this release type: _stopScreencast */
5935 /**
5936 * Captures a screenshot of this {@link Page | page}.
5937 *
5938 * @param options - Configures screenshot behavior.
5939 *
5940 * @remarks
5941 *
5942 * While a screenshot is being taken in a {@link BrowserContext}, the
5943 * following methods will automatically wait for the screenshot to
5944 * finish to prevent interference with the screenshot process:
5945 * {@link BrowserContext.newPage}, {@link Browser.newPage},
5946 * {@link Page.close}.
5947 *
5948 * Calling {@link Page.bringToFront} will not wait for existing
5949 * screenshot operations.
5950 *
5951 */
5952 screenshot(options: Readonly<ScreenshotOptions> & {
5953 encoding: 'base64';
5954 }): Promise<string>;
5955 screenshot(options?: Readonly<ScreenshotOptions>): Promise<Uint8Array>;
5956 /* Excluded from this release type: _screenshot */
5957 /**
5958 * Generates a PDF of the page with the `print` CSS media type.
5959 *
5960 * @param options - options for generating the PDF.
5961 *
5962 * @remarks
5963 *
5964 * To generate a PDF with the `screen` media type, call
5965 * {@link Page.emulateMediaType | `page.emulateMediaType('screen')`} before
5966 * calling `page.pdf()`.
5967 *
5968 * By default, `page.pdf()` generates a pdf with modified colors for printing.
5969 * Use the
5970 * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-print-color-adjust | `-webkit-print-color-adjust`}
5971 * property to force rendering of exact colors.
5972 */
5973 abstract createPDFStream(options?: PDFOptions): Promise<ReadableStream<Uint8Array>>;
5974 /**
5975 * {@inheritDoc Page.createPDFStream}
5976 */
5977 abstract pdf(options?: PDFOptions): Promise<Uint8Array>;
5978 /**
5979 * The page's title
5980 *
5981 * @remarks
5982 *
5983 * Shortcut for {@link Frame.title | page.mainFrame().title()}.
5984 */
5985 title(): Promise<string>;
5986 abstract close(options?: {
5987 runBeforeUnload?: boolean;
5988 }): Promise<void>;
5989 /**
5990 * Indicates that the page has been closed.
5991 * @returns
5992 */
5993 abstract isClosed(): boolean;
5994 /**
5995 * {@inheritDoc Mouse}
5996 */
5997 abstract get mouse(): Mouse;
5998 /**
5999 * This method fetches an element with `selector`, scrolls it into view if
6000 * needed, and then uses {@link Page.mouse} to click in the center of the
6001 * element. If there's no element matching `selector`, the method throws an
6002 * error.
6003 *
6004 * @remarks
6005 *
6006 * Bear in mind that if `click()` triggers a navigation event and
6007 * there's a separate `page.waitForNavigation()` promise to be resolved, you
6008 * may end up with a race condition that yields unexpected results. The
6009 * correct pattern for click and wait for navigation is the following:
6010 *
6011 * ```ts
6012 * const [response] = await Promise.all([
6013 * page.waitForNavigation(waitOptions),
6014 * page.click(selector, clickOptions),
6015 * ]);
6016 * ```
6017 *
6018 * Shortcut for {@link Frame.click | page.mainFrame().click(selector[, options]) }.
6019 * @param selector -
6020 * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
6021 * to query the page for.
6022 * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
6023 * can be passed as-is and a
6024 * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
6025 * allows quering by
6026 * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
6027 * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
6028 * and
6029 * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
6030 * and
6031 * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
6032 * Alternatively, you can specify the selector type using a
6033 * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}. If there are
6034 * multiple elements satisfying the `selector`, the first will be clicked
6035 * @param options - `Object`
6036 * @returns Promise which resolves when the element matching `selector` is
6037 * successfully clicked. The Promise will be rejected if there is no element
6038 * matching `selector`.
6039 */
6040 click(selector: string, options?: Readonly<ClickOptions>): Promise<void>;
6041 /**
6042 * This method fetches an element with `selector` and focuses it. If
6043 * there's no element matching `selector`, the method throws an error.
6044 * @param selector -
6045 * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
6046 * to query the page for.
6047 * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
6048 * can be passed as-is and a
6049 * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
6050 * allows quering by
6051 * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
6052 * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
6053 * and
6054 * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
6055 * and
6056 * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
6057 * Alternatively, you can specify the selector type using a
6058 * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
6059 * If there are multiple elements satisfying the selector, the first
6060 * will be focused.
6061 * @returns Promise which resolves when the element matching selector
6062 * is successfully focused. The promise will be rejected if there is
6063 * no element matching selector.
6064 *
6065 * @remarks
6066 *
6067 * Shortcut for
6068 * {@link Frame.focus | page.mainFrame().focus(selector)}.
6069 */
6070 focus(selector: string): Promise<void>;
6071 /**
6072 * This method fetches an element with `selector`, scrolls it into view if
6073 * needed, and then uses {@link Page.mouse}
6074 * to hover over the center of the element.
6075 * If there's no element matching `selector`, the method throws an error.
6076 * @param selector -
6077 * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
6078 * to query the page for.
6079 * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
6080 * can be passed as-is and a
6081 * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
6082 * allows quering by
6083 * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
6084 * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
6085 * and
6086 * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
6087 * and
6088 * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
6089 * Alternatively, you can specify the selector type using a
6090 * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}. If there are
6091 * multiple elements satisfying the `selector`, the first will be hovered.
6092 * @returns Promise which resolves when the element matching `selector` is
6093 * successfully hovered. Promise gets rejected if there's no element matching
6094 * `selector`.
6095 *
6096 * @remarks
6097 *
6098 * Shortcut for {@link Page.hover | page.mainFrame().hover(selector)}.
6099 */
6100 hover(selector: string): Promise<void>;
6101 /**
6102 * Triggers a `change` and `input` event once all the provided options have been
6103 * selected. If there's no `<select>` element matching `selector`, the method
6104 * throws an error.
6105 *
6106 * @example
6107 *
6108 * ```ts
6109 * page.select('select#colors', 'blue'); // single selection
6110 * page.select('select#colors', 'red', 'green', 'blue'); // multiple selections
6111 * ```
6112 *
6113 * @param selector -
6114 * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
6115 * to query the page for.
6116 * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
6117 * can be passed as-is and a
6118 * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
6119 * allows quering by
6120 * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
6121 * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
6122 * and
6123 * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
6124 * and
6125 * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
6126 * Alternatively, you can specify the selector type using a
6127 * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
6128 * @param values - Values of options to select. If the `<select>` has the
6129 * `multiple` attribute, all values are considered, otherwise only the first one
6130 * is taken into account.
6131 * @returns
6132 *
6133 * @remarks
6134 *
6135 * Shortcut for {@link Frame.select | page.mainFrame().select()}
6136 */
6137 select(selector: string, ...values: string[]): Promise<string[]>;
6138 /**
6139 * This method fetches an element with `selector`, scrolls it into view if
6140 * needed, and then uses {@link Page.touchscreen}
6141 * to tap in the center of the element.
6142 * If there's no element matching `selector`, the method throws an error.
6143 * @param selector -
6144 * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
6145 * to query the page for.
6146 * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
6147 * can be passed as-is and a
6148 * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
6149 * allows quering by
6150 * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
6151 * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
6152 * and
6153 * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
6154 * and
6155 * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
6156 * Alternatively, you can specify the selector type using a
6157 * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}. If there are multiple elements satisfying the
6158 * selector, the first will be tapped.
6159 *
6160 * @remarks
6161 *
6162 * Shortcut for {@link Frame.tap | page.mainFrame().tap(selector)}.
6163 */
6164 tap(selector: string): Promise<void>;
6165 /**
6166 * Sends a `keydown`, `keypress/input`, and `keyup` event for each character
6167 * in the text.
6168 *
6169 * To press a special key, like `Control` or `ArrowDown`, use {@link Keyboard.press}.
6170 * @example
6171 *
6172 * ```ts
6173 * await page.type('#mytextarea', 'Hello');
6174 * // Types instantly
6175 * await page.type('#mytextarea', 'World', {delay: 100});
6176 * // Types slower, like a user
6177 * ```
6178 *
6179 * @param selector -
6180 * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
6181 * to query the page for.
6182 * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
6183 * can be passed as-is and a
6184 * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
6185 * allows quering by
6186 * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
6187 * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
6188 * and
6189 * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
6190 * and
6191 * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
6192 * Alternatively, you can specify the selector type using a
6193 * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
6194 * @param text - A text to type into a focused element.
6195 * @param options - have property `delay` which is the Time to wait between
6196 * key presses in milliseconds. Defaults to `0`.
6197 * @returns
6198 */
6199 type(selector: string, text: string, options?: Readonly<KeyboardTypeOptions>): Promise<void>;
6200 /**
6201 * Wait for the `selector` to appear in page. If at the moment of calling the
6202 * method the `selector` already exists, the method will return immediately. If
6203 * the `selector` doesn't appear after the `timeout` milliseconds of waiting, the
6204 * function will throw.
6205 *
6206 * @example
6207 * This method works across navigations:
6208 *
6209 * ```ts
6210 * import puppeteer from 'puppeteer';
6211 * (async () => {
6212 * const browser = await puppeteer.launch();
6213 * const page = await browser.newPage();
6214 * let currentURL;
6215 * page
6216 * .waitForSelector('img')
6217 * .then(() => console.log('First URL with image: ' + currentURL));
6218 * for (currentURL of [
6219 * 'https://example.com',
6220 * 'https://google.com',
6221 * 'https://bbc.com',
6222 * ]) {
6223 * await page.goto(currentURL);
6224 * }
6225 * await browser.close();
6226 * })();
6227 * ```
6228 *
6229 * @param selector -
6230 * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
6231 * to query the page for.
6232 * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
6233 * can be passed as-is and a
6234 * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
6235 * allows quering by
6236 * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
6237 * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
6238 * and
6239 * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
6240 * and
6241 * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
6242 * Alternatively, you can specify the selector type using a
6243 * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
6244 * @param options - Optional waiting parameters
6245 * @returns Promise which resolves when element specified by selector string
6246 * is added to DOM. Resolves to `null` if waiting for hidden: `true` and
6247 * selector is not found in DOM.
6248 *
6249 * @remarks
6250 * The optional Parameter in Arguments `options` are:
6251 *
6252 * - `visible`: A boolean wait for element to be present in DOM and to be
6253 * visible, i.e. to not have `display: none` or `visibility: hidden` CSS
6254 * properties. Defaults to `false`.
6255 *
6256 * - `hidden`: Wait for element to not be found in the DOM or to be hidden,
6257 * i.e. have `display: none` or `visibility: hidden` CSS properties. Defaults to
6258 * `false`.
6259 *
6260 * - `timeout`: maximum time to wait for in milliseconds. Defaults to `30000`
6261 * (30 seconds). Pass `0` to disable timeout. The default value can be changed
6262 * by using the {@link Page.setDefaultTimeout} method.
6263 */
6264 waitForSelector<Selector extends string>(selector: Selector, options?: WaitForSelectorOptions): Promise<ElementHandle<NodeFor<Selector>> | null>;
6265 /**
6266 * Waits for the provided function, `pageFunction`, to return a truthy value when
6267 * evaluated in the page's context.
6268 *
6269 * @example
6270 * {@link Page.waitForFunction} can be used to observe a viewport size change:
6271 *
6272 * ```ts
6273 * import puppeteer from 'puppeteer';
6274 * (async () => {
6275 * const browser = await puppeteer.launch();
6276 * const page = await browser.newPage();
6277 * const watchDog = page.waitForFunction('window.innerWidth < 100');
6278 * await page.setViewport({width: 50, height: 50});
6279 * await watchDog;
6280 * await browser.close();
6281 * })();
6282 * ```
6283 *
6284 * @example
6285 * Arguments can be passed from Node.js to `pageFunction`:
6286 *
6287 * ```ts
6288 * const selector = '.foo';
6289 * await page.waitForFunction(
6290 * selector => !!document.querySelector(selector),
6291 * {},
6292 * selector
6293 * );
6294 * ```
6295 *
6296 * @example
6297 * The provided `pageFunction` can be asynchronous:
6298 *
6299 * ```ts
6300 * const username = 'github-username';
6301 * await page.waitForFunction(
6302 * async username => {
6303 * const githubResponse = await fetch(
6304 * `https://api.github.com/users/${username}`
6305 * );
6306 * const githubUser = await githubResponse.json();
6307 * // show the avatar
6308 * const img = document.createElement('img');
6309 * img.src = githubUser.avatar_url;
6310 * // wait 3 seconds
6311 * await new Promise((resolve, reject) => setTimeout(resolve, 3000));
6312 * img.remove();
6313 * },
6314 * {},
6315 * username
6316 * );
6317 * ```
6318 *
6319 * @param pageFunction - Function to be evaluated in browser context until it returns a
6320 * truthy value.
6321 * @param options - Options for configuring waiting behavior.
6322 */
6323 waitForFunction<Params extends unknown[], Func extends EvaluateFunc<Params> = EvaluateFunc<Params>>(pageFunction: Func | string, options?: FrameWaitForFunctionOptions, ...args: Params): Promise<HandleFor<Awaited<ReturnType<Func>>>>;
6324 /**
6325 * This method is typically coupled with an action that triggers a device
6326 * request from an api such as WebBluetooth.
6327 *
6328 * :::caution
6329 *
6330 * This must be called before the device request is made. It will not return a
6331 * currently active device prompt.
6332 *
6333 * :::
6334 *
6335 * @example
6336 *
6337 * ```ts
6338 * const [devicePrompt] = Promise.all([
6339 * page.waitForDevicePrompt(),
6340 * page.click('#connect-bluetooth'),
6341 * ]);
6342 * await devicePrompt.select(
6343 * await devicePrompt.waitForDevice(({name}) => name.includes('My Device'))
6344 * );
6345 * ```
6346 */
6347 abstract waitForDevicePrompt(options?: WaitTimeoutOptions): Promise<DeviceRequestPrompt>;
6348 /* Excluded from this release type: [disposeSymbol] */
6349 /* Excluded from this release type: [asyncDisposeSymbol] */
6350}
6351
6352/* Excluded from this release type: PageBinding */
6353
6354/* Excluded from this release type: pageBindingInitString */
6355
6356/**
6357 * All the events that a page instance may emit.
6358 *
6359 * @public
6360 */
6361export declare const enum PageEvent {
6362 /**
6363 * Emitted when the page closes.
6364 */
6365 Close = "close",
6366 /**
6367 * Emitted when JavaScript within the page calls one of console API methods,
6368 * e.g. `console.log` or `console.dir`. Also emitted if the page throws an
6369 * error or a warning.
6370 *
6371 * @remarks
6372 * A `console` event provides a {@link ConsoleMessage} representing the
6373 * console message that was logged.
6374 *
6375 * @example
6376 * An example of handling `console` event:
6377 *
6378 * ```ts
6379 * page.on('console', msg => {
6380 * for (let i = 0; i < msg.args().length; ++i)
6381 * console.log(`${i}: ${msg.args()[i]}`);
6382 * });
6383 * page.evaluate(() => console.log('hello', 5, {foo: 'bar'}));
6384 * ```
6385 */
6386 Console = "console",
6387 /**
6388 * Emitted when a JavaScript dialog appears, such as `alert`, `prompt`,
6389 * `confirm` or `beforeunload`. Puppeteer can respond to the dialog via
6390 * {@link Dialog.accept} or {@link Dialog.dismiss}.
6391 */
6392 Dialog = "dialog",
6393 /**
6394 * Emitted when the JavaScript
6395 * {@link https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded | DOMContentLoaded }
6396 * event is dispatched.
6397 */
6398 DOMContentLoaded = "domcontentloaded",
6399 /**
6400 * Emitted when the page crashes. Will contain an `Error`.
6401 */
6402 Error = "error",
6403 /** Emitted when a frame is attached. Will contain a {@link Frame}. */
6404 FrameAttached = "frameattached",
6405 /** Emitted when a frame is detached. Will contain a {@link Frame}. */
6406 FrameDetached = "framedetached",
6407 /**
6408 * Emitted when a frame is navigated to a new URL. Will contain a
6409 * {@link Frame}.
6410 */
6411 FrameNavigated = "framenavigated",
6412 /**
6413 * Emitted when the JavaScript
6414 * {@link https://developer.mozilla.org/en-US/docs/Web/Events/load | load}
6415 * event is dispatched.
6416 */
6417 Load = "load",
6418 /**
6419 * Emitted when the JavaScript code makes a call to `console.timeStamp`. For
6420 * the list of metrics see {@link Page.metrics | page.metrics}.
6421 *
6422 * @remarks
6423 * Contains an object with two properties:
6424 *
6425 * - `title`: the title passed to `console.timeStamp`
6426 * - `metrics`: object containing metrics as key/value pairs. The values will
6427 * be `number`s.
6428 */
6429 Metrics = "metrics",
6430 /**
6431 * Emitted when an uncaught exception happens within the page. Contains an
6432 * `Error`.
6433 */
6434 PageError = "pageerror",
6435 /**
6436 * Emitted when the page opens a new tab or window.
6437 *
6438 * Contains a {@link Page} corresponding to the popup window.
6439 *
6440 * @example
6441 *
6442 * ```ts
6443 * const [popup] = await Promise.all([
6444 * new Promise(resolve => page.once('popup', resolve)),
6445 * page.click('a[target=_blank]'),
6446 * ]);
6447 * ```
6448 *
6449 * ```ts
6450 * const [popup] = await Promise.all([
6451 * new Promise(resolve => page.once('popup', resolve)),
6452 * page.evaluate(() => window.open('https://example.com')),
6453 * ]);
6454 * ```
6455 */
6456 Popup = "popup",
6457 /**
6458 * Emitted when a page issues a request and contains a {@link HTTPRequest}.
6459 *
6460 * @remarks
6461 * The object is readonly. See {@link Page.setRequestInterception} for
6462 * intercepting and mutating requests.
6463 */
6464 Request = "request",
6465 /**
6466 * Emitted when a request ended up loading from cache. Contains a
6467 * {@link HTTPRequest}.
6468 *
6469 * @remarks
6470 * For certain requests, might contain undefined.
6471 * {@link https://crbug.com/750469}
6472 */
6473 RequestServedFromCache = "requestservedfromcache",
6474 /**
6475 * Emitted when a request fails, for example by timing out.
6476 *
6477 * Contains a {@link HTTPRequest}.
6478 *
6479 * @remarks
6480 * HTTP Error responses, such as 404 or 503, are still successful responses
6481 * from HTTP standpoint, so request will complete with `requestfinished` event
6482 * and not with `requestfailed`.
6483 */
6484 RequestFailed = "requestfailed",
6485 /**
6486 * Emitted when a request finishes successfully. Contains a
6487 * {@link HTTPRequest}.
6488 */
6489 RequestFinished = "requestfinished",
6490 /**
6491 * Emitted when a response is received. Contains a {@link HTTPResponse}.
6492 */
6493 Response = "response",
6494 /**
6495 * Emitted when a dedicated
6496 * {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API | WebWorker}
6497 * is spawned by the page.
6498 */
6499 WorkerCreated = "workercreated",
6500 /**
6501 * Emitted when a dedicated
6502 * {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API | WebWorker}
6503 * is destroyed by the page.
6504 */
6505 WorkerDestroyed = "workerdestroyed"
6506}
6507
6508/**
6509 * Denotes the objects received by callback functions for page events.
6510 *
6511 * See {@link PageEvent} for more detail on the events and when they are
6512 * emitted.
6513 *
6514 * @public
6515 */
6516export declare interface PageEvents extends Record<EventType, unknown> {
6517 [PageEvent.Close]: undefined;
6518 [PageEvent.Console]: ConsoleMessage;
6519 [PageEvent.Dialog]: Dialog;
6520 [PageEvent.DOMContentLoaded]: undefined;
6521 [PageEvent.Error]: Error;
6522 [PageEvent.FrameAttached]: Frame;
6523 [PageEvent.FrameDetached]: Frame;
6524 [PageEvent.FrameNavigated]: Frame;
6525 [PageEvent.Load]: undefined;
6526 [PageEvent.Metrics]: {
6527 title: string;
6528 metrics: Metrics;
6529 };
6530 [PageEvent.PageError]: Error;
6531 [PageEvent.Popup]: Page | null;
6532 [PageEvent.Request]: HTTPRequest;
6533 [PageEvent.Response]: HTTPResponse;
6534 [PageEvent.RequestFailed]: HTTPRequest;
6535 [PageEvent.RequestFinished]: HTTPRequest;
6536 [PageEvent.RequestServedFromCache]: HTTPRequest;
6537 [PageEvent.WorkerCreated]: WebWorker;
6538 [PageEvent.WorkerDestroyed]: WebWorker;
6539}
6540
6541/* Excluded from this release type: PageTarget */
6542
6543/**
6544 * All the valid paper format types when printing a PDF.
6545 *
6546 * @remarks
6547 *
6548 * The sizes of each format are as follows:
6549 *
6550 * - `Letter`: 8.5in x 11in
6551 *
6552 * - `Legal`: 8.5in x 14in
6553 *
6554 * - `Tabloid`: 11in x 17in
6555 *
6556 * - `Ledger`: 17in x 11in
6557 *
6558 * - `A0`: 33.1102in x 46.811in
6559 *
6560 * - `A1`: 23.3858in x 33.1102in
6561 *
6562 * - `A2`: 16.5354in x 23.3858in
6563 *
6564 * - `A3`: 11.6929in x 16.5354in
6565 *
6566 * - `A4`: 8.2677in x 11.6929in
6567 *
6568 * - `A5`: 5.8268in x 8.2677in
6569 *
6570 * - `A6`: 4.1339in x 5.8268in
6571 *
6572 * @public
6573 */
6574export declare type PaperFormat = Uppercase<LowerCasePaperFormat> | Capitalize<LowerCasePaperFormat> | LowerCasePaperFormat;
6575
6576/* Excluded from this release type: PaperFormatDimensions */
6577
6578/* Excluded from this release type: paperFormats */
6579
6580/* Excluded from this release type: ParsedPDFOptions */
6581
6582/* Excluded from this release type: ParsedPDFOptionsInterface */
6583
6584/* Excluded from this release type: parsePDFOptions */
6585
6586/* Excluded from this release type: parsePSelectors */
6587
6588/* Excluded from this release type: PCombinator */
6589
6590/**
6591 * @license
6592 * Copyright 2020 Google Inc.
6593 * SPDX-License-Identifier: Apache-2.0
6594 */
6595/**
6596 * @public
6597 */
6598export declare interface PDFMargin {
6599 top?: string | number;
6600 bottom?: string | number;
6601 left?: string | number;
6602 right?: string | number;
6603}
6604
6605/**
6606 * Valid options to configure PDF generation via {@link Page.pdf}.
6607 * @public
6608 */
6609export declare interface PDFOptions {
6610 /**
6611 * Scales the rendering of the web page. Amount must be between `0.1` and `2`.
6612 * @defaultValue `1`
6613 */
6614 scale?: number;
6615 /**
6616 * Whether to show the header and footer.
6617 * @defaultValue `false`
6618 */
6619 displayHeaderFooter?: boolean;
6620 /**
6621 * HTML template for the print header. Should be valid HTML with the following
6622 * classes used to inject values into them:
6623 *
6624 * - `date` formatted print date
6625 *
6626 * - `title` document title
6627 *
6628 * - `url` document location
6629 *
6630 * - `pageNumber` current page number
6631 *
6632 * - `totalPages` total pages in the document
6633 */
6634 headerTemplate?: string;
6635 /**
6636 * HTML template for the print footer. Has the same constraints and support
6637 * for special classes as {@link PDFOptions.headerTemplate}.
6638 */
6639 footerTemplate?: string;
6640 /**
6641 * Set to `true` to print background graphics.
6642 * @defaultValue `false`
6643 */
6644 printBackground?: boolean;
6645 /**
6646 * Whether to print in landscape orientation.
6647 * @defaultValue `false`
6648 */
6649 landscape?: boolean;
6650 /**
6651 * Paper ranges to print, e.g. `1-5, 8, 11-13`.
6652 * @defaultValue The empty string, which means all pages are printed.
6653 */
6654 pageRanges?: string;
6655 /**
6656 * @remarks
6657 * If set, this takes priority over the `width` and `height` options.
6658 * @defaultValue `letter`.
6659 */
6660 format?: PaperFormat;
6661 /**
6662 * Sets the width of paper. You can pass in a number or a string with a unit.
6663 */
6664 width?: string | number;
6665 /**
6666 * Sets the height of paper. You can pass in a number or a string with a unit.
6667 */
6668 height?: string | number;
6669 /**
6670 * Give any CSS `@page` size declared in the page priority over what is
6671 * declared in the `width` or `height` or `format` option.
6672 * @defaultValue `false`, which will scale the content to fit the paper size.
6673 */
6674 preferCSSPageSize?: boolean;
6675 /**
6676 * Set the PDF margins.
6677 * @defaultValue `undefined` no margins are set.
6678 */
6679 margin?: PDFMargin;
6680 /**
6681 * The path to save the file to.
6682 *
6683 * @remarks
6684 *
6685 * If the path is relative, it's resolved relative to the current working directory.
6686 *
6687 * @defaultValue `undefined`, which means the PDF will not be written to disk.
6688 */
6689 path?: string;
6690 /**
6691 * Hides default white background and allows generating pdfs with transparency.
6692 * @defaultValue `false`
6693 */
6694 omitBackground?: boolean;
6695 /**
6696 * Generate tagged (accessible) PDF.
6697 *
6698 * @defaultValue `true`
6699 * @experimental
6700 */
6701 tagged?: boolean;
6702 /**
6703 * Generate document outline.
6704 *
6705 * @defaultValue `false`
6706 * @experimental
6707 */
6708 outline?: boolean;
6709 /**
6710 * Timeout in milliseconds. Pass `0` to disable timeout.
6711 *
6712 * The default value can be changed by using {@link Page.setDefaultTimeout}
6713 *
6714 * @defaultValue `30_000`
6715 */
6716 timeout?: number;
6717 /**
6718 * If true, waits for `document.fonts.ready` to resolve. This might require
6719 * activating the page using {@link Page.bringToFront} if the page is in the
6720 * background.
6721 *
6722 * @defaultValue `true`
6723 */
6724 waitForFonts?: boolean;
6725}
6726
6727/**
6728 * @public
6729 */
6730export declare type Permission = 'geolocation' | 'midi' | 'notifications' | 'camera' | 'microphone' | 'background-sync' | 'ambient-light-sensor' | 'accelerometer' | 'gyroscope' | 'magnetometer' | 'accessibility-events' | 'clipboard-read' | 'clipboard-write' | 'clipboard-sanitized-write' | 'payment-handler' | 'persistent-storage' | 'idle-detection' | 'midi-sysex';
6731
6732/* Excluded from this release type: PierceQueryHandler */
6733
6734/* Excluded from this release type: PipeTransport */
6735
6736/**
6737 * @public
6738 */
6739export declare interface Point {
6740 x: number;
6741 y: number;
6742}
6743
6744/* Excluded from this release type: Poller */
6745
6746/* Excluded from this release type: PollingOptions */
6747
6748/* Excluded from this release type: PPseudoSelector */
6749
6750/* Excluded from this release type: PQueryHandler */
6751
6752declare namespace PQuerySelector {
6753 export {
6754
6755 }
6756}
6757
6758/* Excluded from this release type: pQuerySelector */
6759
6760/* Excluded from this release type: pQuerySelectorAll */
6761
6762/**
6763 * A list of pre-defined network conditions to be used with
6764 * {@link Page.emulateNetworkConditions}.
6765 *
6766 * @example
6767 *
6768 * ```ts
6769 * import {PredefinedNetworkConditions} from 'puppeteer';
6770 * (async () => {
6771 * const browser = await puppeteer.launch();
6772 * const page = await browser.newPage();
6773 * await page.emulateNetworkConditions(
6774 * PredefinedNetworkConditions['Slow 3G']
6775 * );
6776 * await page.goto('https://www.google.com');
6777 * await page.emulateNetworkConditions(
6778 * PredefinedNetworkConditions['Fast 3G']
6779 * );
6780 * await page.goto('https://www.google.com');
6781 * await page.emulateNetworkConditions(
6782 * PredefinedNetworkConditions['Slow 4G']
6783 * ); // alias to Fast 3G.
6784 * await page.goto('https://www.google.com');
6785 * await page.emulateNetworkConditions(
6786 * PredefinedNetworkConditions['Fast 4G']
6787 * );
6788 * await page.goto('https://www.google.com');
6789 * // other actions...
6790 * await browser.close();
6791 * })();
6792 * ```
6793 *
6794 * @public
6795 */
6796export declare const PredefinedNetworkConditions: Readonly<{
6797 'Slow 3G': NetworkConditions;
6798 'Fast 3G': NetworkConditions;
6799 'Slow 4G': NetworkConditions;
6800 'Fast 4G': NetworkConditions;
6801}>;
6802
6803/**
6804 * @public
6805 */
6806export declare type Predicate<From, To extends From = From> = ((value: From) => value is To) | ((value: From) => Awaitable<boolean>);
6807
6808export { Protocol }
6809
6810/**
6811 * ProtocolError is emitted whenever there is an error from the protocol.
6812 *
6813 * @public
6814 */
6815export declare class ProtocolError extends PuppeteerError {
6816 #private;
6817 set code(code: number | undefined);
6818 /**
6819 * @readonly
6820 * @public
6821 */
6822 get code(): number | undefined;
6823 set originalMessage(originalMessage: string);
6824 /**
6825 * @readonly
6826 * @public
6827 */
6828 get originalMessage(): string;
6829}
6830
6831/**
6832 * @public
6833 */
6834export declare type ProtocolLifeCycleEvent = 'load' | 'DOMContentLoaded' | 'networkIdle' | 'networkAlmostIdle';
6835
6836/**
6837 * @public
6838 */
6839export declare type ProtocolType = 'cdp' | 'webDriverBiDi';
6840
6841/**
6842 * The main Puppeteer class.
6843 *
6844 * IMPORTANT: if you are using Puppeteer in a Node environment, you will get an
6845 * instance of {@link PuppeteerNode} when you import or require `puppeteer`.
6846 * That class extends `Puppeteer`, so has all the methods documented below as
6847 * well as all that are defined on {@link PuppeteerNode}.
6848 *
6849 * @public
6850 */
6851export declare class Puppeteer {
6852 /* Excluded from this release type: customQueryHandlers */
6853 /**
6854 * Registers a {@link CustomQueryHandler | custom query handler}.
6855 *
6856 * @remarks
6857 * After registration, the handler can be used everywhere where a selector is
6858 * expected by prepending the selection string with `<name>/`. The name is only
6859 * allowed to consist of lower- and upper case latin letters.
6860 *
6861 * @example
6862 *
6863 * ```
6864 * import {Puppeteer}, puppeteer from 'puppeteer';
6865 *
6866 * Puppeteer.registerCustomQueryHandler('text', { … });
6867 * const aHandle = await page.$('text/…');
6868 * ```
6869 *
6870 * @param name - The name that the custom query handler will be registered
6871 * under.
6872 * @param queryHandler - The {@link CustomQueryHandler | custom query handler}
6873 * to register.
6874 *
6875 * @public
6876 */
6877 static registerCustomQueryHandler(name: string, queryHandler: CustomQueryHandler): void;
6878 /**
6879 * Unregisters a custom query handler for a given name.
6880 */
6881 static unregisterCustomQueryHandler(name: string): void;
6882 /**
6883 * Gets the names of all custom query handlers.
6884 */
6885 static customQueryHandlerNames(): string[];
6886 /**
6887 * Unregisters all custom query handlers.
6888 */
6889 static clearCustomQueryHandlers(): void;
6890 /* Excluded from this release type: _isPuppeteerCore */
6891 /* Excluded from this release type: _changedBrowsers */
6892 /* Excluded from this release type: __constructor */
6893 /**
6894 * This method attaches Puppeteer to an existing browser instance.
6895 *
6896 * @remarks
6897 *
6898 * @param options - Set of configurable options to set on the browser.
6899 * @returns Promise which resolves to browser instance.
6900 */
6901 connect(options: ConnectOptions): Promise<Browser>;
6902}
6903
6904/**
6905 * @public
6906 */
6907declare const puppeteer: PuppeteerNode;
6908export default puppeteer;
6909
6910/* Excluded from this release type: PUPPETEER_REVISIONS */
6911
6912/* Excluded from this release type: PUPPETEER_WORLD */
6913
6914/**
6915 * @license
6916 * Copyright 2018 Google Inc.
6917 * SPDX-License-Identifier: Apache-2.0
6918 */
6919/**
6920 * The base class for all Puppeteer-specific errors
6921 *
6922 * @public
6923 */
6924export declare class PuppeteerError extends Error {
6925 /* Excluded from this release type: __constructor */
6926 /* Excluded from this release type: [Symbol.toStringTag] */
6927}
6928
6929/**
6930 * @public
6931 */
6932export declare interface PuppeteerLaunchOptions extends LaunchOptions, BrowserLaunchArgumentOptions, BrowserConnectOptions {
6933 browser?: SupportedBrowser;
6934 extraPrefsFirefox?: Record<string, unknown>;
6935}
6936
6937/**
6938 * @public
6939 */
6940export declare type PuppeteerLifeCycleEvent =
6941/**
6942* Waits for the 'load' event.
6943*/
6944'load'
6945/**
6946* Waits for the 'DOMContentLoaded' event.
6947*/
6948| 'domcontentloaded'
6949/**
6950* Waits till there are no more than 0 network connections for at least `500`
6951* ms.
6952*/
6953| 'networkidle0'
6954/**
6955* Waits till there are no more than 2 network connections for at least `500`
6956* ms.
6957*/
6958| 'networkidle2';
6959
6960/**
6961 * Extends the main {@link Puppeteer} class with Node specific behaviour for
6962 * fetching and downloading browsers.
6963 *
6964 * If you're using Puppeteer in a Node environment, this is the class you'll get
6965 * when you run `require('puppeteer')` (or the equivalent ES `import`).
6966 *
6967 * @remarks
6968 * The most common method to use is {@link PuppeteerNode.launch | launch}, which
6969 * is used to launch and connect to a new browser instance.
6970 *
6971 * See {@link Puppeteer | the main Puppeteer class} for methods common to all
6972 * environments, such as {@link Puppeteer.connect}.
6973 *
6974 * @example
6975 * The following is a typical example of using Puppeteer to drive automation:
6976 *
6977 * ```ts
6978 * import puppeteer from 'puppeteer';
6979 *
6980 * (async () => {
6981 * const browser = await puppeteer.launch();
6982 * const page = await browser.newPage();
6983 * await page.goto('https://www.google.com');
6984 * // other actions...
6985 * await browser.close();
6986 * })();
6987 * ```
6988 *
6989 * Once you have created a `page` you have access to a large API to interact
6990 * with the page, navigate, or find certain elements in that page.
6991 * The {@link Page | `page` documentation} lists all the available methods.
6992 *
6993 * @public
6994 */
6995export declare class PuppeteerNode extends Puppeteer {
6996 #private;
6997 /* Excluded from this release type: defaultBrowserRevision */
6998 /* Excluded from this release type: configuration */
6999 /* Excluded from this release type: __constructor */
7000 /**
7001 * This method attaches Puppeteer to an existing browser instance.
7002 *
7003 * @param options - Set of configurable options to set on the browser.
7004 * @returns Promise which resolves to browser instance.
7005 */
7006 connect(options: ConnectOptions): Promise<Browser>;
7007 /**
7008 * Launches a browser instance with given arguments and options when
7009 * specified.
7010 *
7011 * When using with `puppeteer-core`,
7012 * {@link LaunchOptions.executablePath | options.executablePath} or
7013 * {@link LaunchOptions.channel | options.channel} must be provided.
7014 *
7015 * @example
7016 * You can use {@link LaunchOptions.ignoreDefaultArgs | options.ignoreDefaultArgs}
7017 * to filter out `--mute-audio` from default arguments:
7018 *
7019 * ```ts
7020 * const browser = await puppeteer.launch({
7021 * ignoreDefaultArgs: ['--mute-audio'],
7022 * });
7023 * ```
7024 *
7025 * @remarks
7026 * Puppeteer can also be used to control the Chrome browser, but it works best
7027 * with the version of Chrome for Testing downloaded by default.
7028 * There is no guarantee it will work with any other version. If Google Chrome
7029 * (rather than Chrome for Testing) is preferred, a
7030 * {@link https://www.google.com/chrome/browser/canary.html | Chrome Canary}
7031 * or
7032 * {@link https://www.chromium.org/getting-involved/dev-channel | Dev Channel}
7033 * build is suggested. See
7034 * {@link https://www.howtogeek.com/202825/what%E2%80%99s-the-difference-between-chromium-and-chrome/ | this article}
7035 * for a description of the differences between Chromium and Chrome.
7036 * {@link https://chromium.googlesource.com/chromium/src/+/lkgr/docs/chromium_browser_vs_google_chrome.md | This article}
7037 * describes some differences for Linux users. See
7038 * {@link https://developer.chrome.com/blog/chrome-for-testing/ | this doc} for the description
7039 * of Chrome for Testing.
7040 *
7041 * @param options - Options to configure launching behavior.
7042 */
7043 launch(options?: PuppeteerLaunchOptions): Promise<Browser>;
7044 /**
7045 * The default executable path.
7046 */
7047 executablePath(channel?: ChromeReleaseChannel): string;
7048 /* Excluded from this release type: browserVersion */
7049 /* Excluded from this release type: defaultDownloadPath */
7050 /**
7051 * The name of the browser that was last launched.
7052 */
7053 get lastLaunchedBrowser(): SupportedBrowser;
7054 /**
7055 * The name of the browser that will be launched by default. For
7056 * `puppeteer`, this is influenced by your configuration. Otherwise, it's
7057 * `chrome`.
7058 */
7059 get defaultBrowser(): SupportedBrowser;
7060 /**
7061 * @deprecated Do not use as this field as it does not take into account
7062 * multiple browsers of different types. Use
7063 * {@link PuppeteerNode.defaultBrowser | defaultBrowser} or
7064 * {@link PuppeteerNode.lastLaunchedBrowser | lastLaunchedBrowser}.
7065 *
7066 * @returns The name of the browser that is under automation.
7067 */
7068 get product(): string;
7069 /**
7070 * @param options - Set of configurable options to set on the browser.
7071 *
7072 * @returns The default flags that Chromium will be launched with.
7073 */
7074 defaultArgs(options?: BrowserLaunchArgumentOptions): string[];
7075 /**
7076 * Removes all non-current Firefox and Chrome binaries in the cache directory
7077 * identified by the provided Puppeteer configuration. The current browser
7078 * version is determined by resolving PUPPETEER_REVISIONS from Puppeteer
7079 * unless `configuration.browserRevision` is provided.
7080 *
7081 * @remarks
7082 *
7083 * Note that the method does not check if any other Puppeteer versions
7084 * installed on the host that use the same cache directory require the
7085 * non-current binaries.
7086 *
7087 * @public
7088 */
7089 trimCache(): Promise<void>;
7090}
7091
7092/**
7093 * Utility type exposed to enable users to define options that can be passed to
7094 * `puppeteer.launch` without having to list the set of all types.
7095 * @public
7096 */
7097export declare type PuppeteerNodeLaunchOptions = BrowserLaunchArgumentOptions & LaunchOptions & BrowserConnectOptions;
7098
7099/* Excluded from this release type: PuppeteerURL */
7100
7101/* Excluded from this release type: PuppeteerUtil */
7102
7103/* Excluded from this release type: PuppeteerUtilWrapper */
7104
7105/**
7106 * @public
7107 */
7108export declare type Quad = [Point, Point, Point, Point];
7109
7110/* Excluded from this release type: QueryHandler */
7111
7112/**
7113 * @public
7114 */
7115export declare interface QueryOptions {
7116 /**
7117 * Whether to run the query in isolation. When returning many elements
7118 * from {@link Page.$$} or similar methods, it might be useful to turn
7119 * off the isolation to improve performance. By default, the querying
7120 * code will be executed in a separate sandbox realm.
7121 *
7122 * @defaultValue `true`
7123 */
7124 isolate: boolean;
7125}
7126
7127/* Excluded from this release type: QuerySelector */
7128
7129/* Excluded from this release type: QuerySelectorAll */
7130
7131/* Excluded from this release type: QueuedEventGroup */
7132
7133/* Excluded from this release type: RaceLocator */
7134
7135/* Excluded from this release type: RAFPoller */
7136
7137/* Excluded from this release type: Realm */
7138
7139/* Excluded from this release type: RedirectInfo */
7140
7141/* Excluded from this release type: releaseObject */
7142
7143/**
7144 * @public
7145 */
7146export declare interface RemoteAddress {
7147 ip?: string;
7148 port?: number;
7149}
7150
7151/* Excluded from this release type: removeMatchingFlags */
7152
7153/* Excluded from this release type: ResolvedLaunchArgs */
7154
7155/**
7156 * Resource types for HTTPRequests as perceived by the rendering engine.
7157 *
7158 * @public
7159 */
7160export declare type ResourceType = Lowercase<Protocol.Network.ResourceType>;
7161
7162/**
7163 * Required response data to fulfill a request with.
7164 *
7165 * @public
7166 */
7167export declare interface ResponseForRequest {
7168 status: number;
7169 /**
7170 * Optional response headers. All values are converted to strings.
7171 */
7172 headers: Record<string, unknown>;
7173 contentType: string;
7174 body: string | Uint8Array;
7175}
7176
7177/* Excluded from this release type: RETRY_DELAY */
7178
7179/* Excluded from this release type: rewriteError */
7180
7181/**
7182 * @public
7183 * @experimental
7184 */
7185export declare interface ScreencastOptions {
7186 /**
7187 * File path to save the screencast to.
7188 */
7189 path?: `${string}.webm`;
7190 /**
7191 * Specifies the region of the viewport to crop.
7192 */
7193 crop?: BoundingBox;
7194 /**
7195 * Scales the output video.
7196 *
7197 * For example, `0.5` will shrink the width and height of the output video by
7198 * half. `2` will double the width and height of the output video.
7199 *
7200 * @defaultValue `1`
7201 */
7202 scale?: number;
7203 /**
7204 * Specifies the speed to record at.
7205 *
7206 * For example, `0.5` will slowdown the output video by 50%. `2` will double the
7207 * speed of the output video.
7208 *
7209 * @defaultValue `1`
7210 */
7211 speed?: number;
7212 /**
7213 * Path to the {@link https://ffmpeg.org/ | ffmpeg}.
7214 *
7215 * Required if `ffmpeg` is not in your PATH.
7216 */
7217 ffmpegPath?: string;
7218}
7219
7220/**
7221 * @public
7222 */
7223export declare class ScreenRecorder extends PassThrough {
7224 #private;
7225 /* Excluded from this release type: __constructor */
7226 /**
7227 * Stops the recorder.
7228 *
7229 * @public
7230 */
7231 stop(): Promise<void>;
7232 /* Excluded from this release type: [asyncDisposeSymbol] */
7233}
7234
7235/* Excluded from this release type: ScreenRecorderOptions */
7236
7237/**
7238 * @public
7239 */
7240export declare interface ScreenshotClip extends BoundingBox {
7241 /**
7242 * @defaultValue `1`
7243 */
7244 scale?: number;
7245}
7246
7247/**
7248 * @public
7249 */
7250export declare interface ScreenshotOptions {
7251 /**
7252 * @defaultValue `false`
7253 */
7254 optimizeForSpeed?: boolean;
7255 /**
7256 * @defaultValue `'png'`
7257 */
7258 type?: 'png' | 'jpeg' | 'webp';
7259 /**
7260 * Quality of the image, between 0-100. Not applicable to `png` images.
7261 */
7262 quality?: number;
7263 /**
7264 * Capture the screenshot from the surface, rather than the view.
7265 *
7266 * @defaultValue `true`
7267 */
7268 fromSurface?: boolean;
7269 /**
7270 * When `true`, takes a screenshot of the full page.
7271 *
7272 * @defaultValue `false`
7273 */
7274 fullPage?: boolean;
7275 /**
7276 * Hides default white background and allows capturing screenshots with transparency.
7277 *
7278 * @defaultValue `false`
7279 */
7280 omitBackground?: boolean;
7281 /**
7282 * The file path to save the image to. The screenshot type will be inferred
7283 * from file extension. If path is a relative path, then it is resolved
7284 * relative to current working directory. If no path is provided, the image
7285 * won't be saved to the disk.
7286 */
7287 path?: string;
7288 /**
7289 * Specifies the region of the page/element to clip.
7290 */
7291 clip?: ScreenshotClip;
7292 /**
7293 * Encoding of the image.
7294 *
7295 * @defaultValue `'binary'`
7296 */
7297 encoding?: 'base64' | 'binary';
7298 /**
7299 * Capture the screenshot beyond the viewport.
7300 *
7301 * @defaultValue `false` if there is no `clip`. `true` otherwise.
7302 */
7303 captureBeyondViewport?: boolean;
7304}
7305
7306/* Excluded from this release type: ScriptInjector */
7307
7308/* Excluded from this release type: scriptInjector */
7309
7310/**
7311 * The SecurityDetails class represents the security details of a
7312 * response that was received over a secure connection.
7313 *
7314 * @public
7315 */
7316export declare class SecurityDetails {
7317 #private;
7318 /* Excluded from this release type: __constructor */
7319 /**
7320 * The name of the issuer of the certificate.
7321 */
7322 issuer(): string;
7323 /**
7324 * {@link https://en.wikipedia.org/wiki/Unix_time | Unix timestamp}
7325 * marking the start of the certificate's validity.
7326 */
7327 validFrom(): number;
7328 /**
7329 * {@link https://en.wikipedia.org/wiki/Unix_time | Unix timestamp}
7330 * marking the end of the certificate's validity.
7331 */
7332 validTo(): number;
7333 /**
7334 * The security protocol being used, e.g. "TLS 1.2".
7335 */
7336 protocol(): string;
7337 /**
7338 * The name of the subject to which the certificate was issued.
7339 */
7340 subjectName(): string;
7341 /**
7342 * The list of {@link https://en.wikipedia.org/wiki/Subject_Alternative_Name | subject alternative names (SANs)} of the certificate.
7343 */
7344 subjectAlternativeNames(): string[];
7345}
7346
7347/**
7348 * Represents a Node and the properties of it that are relevant to Accessibility.
7349 * @public
7350 */
7351export declare interface SerializedAXNode {
7352 /**
7353 * The {@link https://www.w3.org/TR/wai-aria/#usage_intro | role} of the node.
7354 */
7355 role: string;
7356 /**
7357 * A human readable name for the node.
7358 */
7359 name?: string;
7360 /**
7361 * The current value of the node.
7362 */
7363 value?: string | number;
7364 /**
7365 * An additional human readable description of the node.
7366 */
7367 description?: string;
7368 /**
7369 * Any keyboard shortcuts associated with this node.
7370 */
7371 keyshortcuts?: string;
7372 /**
7373 * A human readable alternative to the role.
7374 */
7375 roledescription?: string;
7376 /**
7377 * A description of the current value.
7378 */
7379 valuetext?: string;
7380 disabled?: boolean;
7381 expanded?: boolean;
7382 focused?: boolean;
7383 modal?: boolean;
7384 multiline?: boolean;
7385 /**
7386 * Whether more than one child can be selected.
7387 */
7388 multiselectable?: boolean;
7389 readonly?: boolean;
7390 required?: boolean;
7391 selected?: boolean;
7392 /**
7393 * Whether the checkbox is checked, or in a
7394 * {@link https://www.w3.org/TR/wai-aria-practices/examples/checkbox/checkbox-2/checkbox-2.html | mixed state}.
7395 */
7396 checked?: boolean | 'mixed';
7397 /**
7398 * Whether the node is checked or in a mixed state.
7399 */
7400 pressed?: boolean | 'mixed';
7401 /**
7402 * The level of a heading.
7403 */
7404 level?: number;
7405 valuemin?: number;
7406 valuemax?: number;
7407 autocomplete?: string;
7408 haspopup?: string;
7409 /**
7410 * Whether and in what way this node's value is invalid.
7411 */
7412 invalid?: string;
7413 orientation?: string;
7414 /**
7415 * Children of this node, if there are any.
7416 */
7417 children?: SerializedAXNode[];
7418 /**
7419 * Get an ElementHandle for this AXNode if available.
7420 *
7421 * If the underlying DOM element has been disposed, the method might return an
7422 * error.
7423 */
7424 elementHandle(): Promise<ElementHandle | null>;
7425}
7426
7427export { Session }
7428
7429/* Excluded from this release type: setDefaultScreenshotOptions */
7430
7431/* Excluded from this release type: setLogCapture */
7432
7433/**
7434 * @public
7435 */
7436export declare interface SnapshotOptions {
7437 /**
7438 * Prune uninteresting nodes from the tree.
7439 * @defaultValue `true`
7440 */
7441 interestingOnly?: boolean;
7442 /**
7443 * Root node to get the accessibility tree for
7444 * @defaultValue The root node of the entire page.
7445 */
7446 root?: ElementHandle<Node>;
7447}
7448
7449/* Excluded from this release type: SOURCE_URL_REGEX */
7450
7451/* Excluded from this release type: STATUS_TEXTS */
7452
7453/**
7454 * @license
7455 * Copyright 2020 Google Inc.
7456 * SPDX-License-Identifier: Apache-2.0
7457 */
7458/**
7459 * Browsers supported by Puppeteer.
7460 *
7461 * @public
7462 */
7463export declare type SupportedBrowser = 'chrome' | 'firefox';
7464
7465/* Excluded from this release type: supportedMetrics */
7466
7467/**
7468 * WebDriver BiDi capabilities that are not set by Puppeteer itself.
7469 *
7470 * @public
7471 */
7472export declare interface SupportedWebDriverCapabilities {
7473 firstMatch?: SupportedWebDriverCapability[];
7474 alwaysMatch?: SupportedWebDriverCapability;
7475}
7476
7477export declare type SupportedWebDriverCapability = Exclude<Session.CapabilityRequest, 'unhandledPromptBehavior' | 'acceptInsecureCerts'>;
7478
7479/**
7480 * Target represents a
7481 * {@link https://chromedevtools.github.io/devtools-protocol/tot/Target/ | CDP target}.
7482 * In CDP a target is something that can be debugged such a frame, a page or a
7483 * worker.
7484 * @public
7485 */
7486export declare abstract class Target {
7487 /* Excluded from this release type: __constructor */
7488 /**
7489 * If the target is not of type `"service_worker"` or `"shared_worker"`, returns `null`.
7490 */
7491 worker(): Promise<WebWorker | null>;
7492 /**
7493 * If the target is not of type `"page"`, `"webview"` or `"background_page"`,
7494 * returns `null`.
7495 */
7496 page(): Promise<Page | null>;
7497 /**
7498 * Forcefully creates a page for a target of any type. It is useful if you
7499 * want to handle a CDP target of type `other` as a page. If you deal with a
7500 * regular page target, use {@link Target.page}.
7501 */
7502 abstract asPage(): Promise<Page>;
7503 abstract url(): string;
7504 /**
7505 * Creates a Chrome Devtools Protocol session attached to the target.
7506 */
7507 abstract createCDPSession(): Promise<CDPSession>;
7508 /**
7509 * Identifies what kind of target this is.
7510 *
7511 * @remarks
7512 *
7513 * See {@link https://developer.chrome.com/extensions/background_pages | docs} for more info about background pages.
7514 */
7515 abstract type(): TargetType;
7516 /**
7517 * Get the browser the target belongs to.
7518 */
7519 abstract browser(): Browser;
7520 /**
7521 * Get the browser context the target belongs to.
7522 */
7523 abstract browserContext(): BrowserContext;
7524 /**
7525 * Get the target that opened this target. Top-level targets return `null`.
7526 */
7527 abstract opener(): Target | undefined;
7528}
7529
7530/* Excluded from this release type: TargetCloseError */
7531
7532/* Excluded from this release type: TargetFactory */
7533
7534/**
7535 * @public
7536 */
7537export declare type TargetFilterCallback = (target: Target) => boolean;
7538
7539/* Excluded from this release type: TargetManager */
7540
7541/* Excluded from this release type: TargetManagerEvent */
7542
7543/* Excluded from this release type: TargetManagerEvents */
7544
7545/**
7546 * @public
7547 */
7548export declare enum TargetType {
7549 PAGE = "page",
7550 BACKGROUND_PAGE = "background_page",
7551 SERVICE_WORKER = "service_worker",
7552 SHARED_WORKER = "shared_worker",
7553 BROWSER = "browser",
7554 WEBVIEW = "webview",
7555 OTHER = "other",
7556 /* Excluded from this release type: TAB */
7557}
7558
7559/* Excluded from this release type: TaskManager */
7560
7561/* Excluded from this release type: TaskQueue */
7562
7563/* Excluded from this release type: TextContent */
7564
7565/* Excluded from this release type: TextQueryHandler */
7566
7567/* Excluded from this release type: throwIfDetached */
7568
7569/* Excluded from this release type: timeout */
7570
7571/**
7572 * TimeoutError is emitted whenever certain operations are terminated due to
7573 * timeout.
7574 *
7575 * @remarks
7576 * Example operations are {@link Page.waitForSelector | page.waitForSelector} or
7577 * {@link PuppeteerNode.launch | puppeteer.launch}.
7578 *
7579 * @public
7580 */
7581export declare class TimeoutError extends PuppeteerError {
7582}
7583
7584/* Excluded from this release type: TimeoutSettings */
7585
7586/**
7587 * The Touchscreen class exposes touchscreen events.
7588 * @public
7589 */
7590export declare abstract class Touchscreen {
7591 /* Excluded from this release type: __constructor */
7592 /**
7593 * Dispatches a `touchstart` and `touchend` event.
7594 * @param x - Horizontal position of the tap.
7595 * @param y - Vertical position of the tap.
7596 */
7597 tap(x: number, y: number): Promise<void>;
7598 /**
7599 * Dispatches a `touchstart` event.
7600 * @param x - Horizontal position of the tap.
7601 * @param y - Vertical position of the tap.
7602 */
7603 abstract touchStart(x: number, y: number): Promise<void>;
7604 /**
7605 * Dispatches a `touchMove` event.
7606 * @param x - Horizontal position of the move.
7607 * @param y - Vertical position of the move.
7608 *
7609 * @remarks
7610 *
7611 * Not every `touchMove` call results in a `touchmove` event being emitted,
7612 * depending on the browser's optimizations. For example, Chrome
7613 * {@link https://developer.chrome.com/blog/a-more-compatible-smoother-touch/#chromes-new-model-the-throttled-async-touchmove-model | throttles}
7614 * touch move events.
7615 */
7616 abstract touchMove(x: number, y: number): Promise<void>;
7617 /**
7618 * Dispatches a `touchend` event.
7619 */
7620 abstract touchEnd(): Promise<void>;
7621}
7622
7623/**
7624 * The Tracing class exposes the tracing audit interface.
7625 * @remarks
7626 * You can use `tracing.start` and `tracing.stop` to create a trace file
7627 * which can be opened in Chrome DevTools or {@link https://chromedevtools.github.io/timeline-viewer/ | timeline viewer}.
7628 *
7629 * @example
7630 *
7631 * ```ts
7632 * await page.tracing.start({path: 'trace.json'});
7633 * await page.goto('https://www.google.com');
7634 * await page.tracing.stop();
7635 * ```
7636 *
7637 * @public
7638 */
7639export declare class Tracing {
7640 #private;
7641 /* Excluded from this release type: __constructor */
7642 /* Excluded from this release type: updateClient */
7643 /**
7644 * Starts a trace for the current page.
7645 * @remarks
7646 * Only one trace can be active at a time per browser.
7647 *
7648 * @param options - Optional `TracingOptions`.
7649 */
7650 start(options?: TracingOptions): Promise<void>;
7651 /**
7652 * Stops a trace started with the `start` method.
7653 * @returns Promise which resolves to buffer with trace data.
7654 */
7655 stop(): Promise<Uint8Array | undefined>;
7656}
7657
7658/**
7659 * @public
7660 */
7661export declare interface TracingOptions {
7662 path?: string;
7663 screenshots?: boolean;
7664 categories?: string[];
7665}
7666
7667/* Excluded from this release type: transposeIterableHandle */
7668
7669/**
7670 * @public
7671 */
7672export declare const
7673/**
7674* @public
7675*/
7676/**
7677 * @public
7678 */
7679trimCache: () => Promise<void>;
7680
7681/* Excluded from this release type: unitToPixels */
7682
7683/**
7684 * Puppeteer will throw this error if a method is not
7685 * supported by the currently used protocol
7686 *
7687 * @public
7688 */
7689export declare class UnsupportedOperation extends PuppeteerError {
7690}
7691
7692/* Excluded from this release type: UTILITY_WORLD_NAME */
7693
7694/* Excluded from this release type: validateDialogType */
7695
7696/* Excluded from this release type: valueFromRemoteObject */
7697
7698/**
7699 * @license
7700 * Copyright 2020 Google Inc.
7701 * SPDX-License-Identifier: Apache-2.0
7702 */
7703/**
7704 * @public
7705 */
7706export declare interface Viewport {
7707 /**
7708 * The page width in CSS pixels.
7709 *
7710 * @remarks
7711 * Setting this value to `0` will reset this value to the system default.
7712 */
7713 width: number;
7714 /**
7715 * The page height in CSS pixels.
7716 *
7717 * @remarks
7718 * Setting this value to `0` will reset this value to the system default.
7719 */
7720 height: number;
7721 /**
7722 * Specify device scale factor.
7723 * See {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio | devicePixelRatio} for more info.
7724 *
7725 * @remarks
7726 * Setting this value to `0` will reset this value to the system default.
7727 *
7728 * @defaultValue `1`
7729 */
7730 deviceScaleFactor?: number;
7731 /**
7732 * Whether the `meta viewport` tag is taken into account.
7733 * @defaultValue `false`
7734 */
7735 isMobile?: boolean;
7736 /**
7737 * Specifies if the viewport is in landscape mode.
7738 * @defaultValue `false`
7739 */
7740 isLandscape?: boolean;
7741 /**
7742 * Specify if the viewport supports touch events.
7743 * @defaultValue `false`
7744 */
7745 hasTouch?: boolean;
7746}
7747
7748/**
7749 * Whether to wait for the element to be
7750 * {@link ElementHandle.isVisible | visible} or
7751 * {@link ElementHandle.isHidden | hidden}.
7752 * `null` to disable visibility checks.
7753 *
7754 * @public
7755 */
7756export declare type VisibilityOption = 'hidden' | 'visible' | null;
7757
7758/**
7759 * @public
7760 */
7761export declare interface WaitForNetworkIdleOptions extends WaitTimeoutOptions {
7762 /**
7763 * Time (in milliseconds) the network should be idle.
7764 *
7765 * @defaultValue `500`
7766 */
7767 idleTime?: number;
7768 /**
7769 * Maximum number concurrent of network connections to be considered inactive.
7770 *
7771 * @defaultValue `0`
7772 */
7773 concurrency?: number;
7774}
7775
7776/**
7777 * @public
7778 */
7779export declare interface WaitForOptions {
7780 /**
7781 * Maximum wait time in milliseconds. Pass 0 to disable the timeout.
7782 *
7783 * The default value can be changed by using the
7784 * {@link Page.setDefaultTimeout} or {@link Page.setDefaultNavigationTimeout}
7785 * methods.
7786 *
7787 * @defaultValue `30000`
7788 */
7789 timeout?: number;
7790 /**
7791 * When to consider waiting succeeds. Given an array of event strings, waiting
7792 * is considered to be successful after all events have been fired.
7793 *
7794 * @defaultValue `'load'`
7795 */
7796 waitUntil?: PuppeteerLifeCycleEvent | PuppeteerLifeCycleEvent[];
7797 /* Excluded from this release type: ignoreSameDocumentNavigation */
7798 /**
7799 * A signal object that allows you to cancel the call.
7800 */
7801 signal?: AbortSignal;
7802}
7803
7804/**
7805 * @public
7806 */
7807export declare interface WaitForSelectorOptions {
7808 /**
7809 * Wait for the selected element to be present in DOM and to be visible. See
7810 * {@link ElementHandle.isVisible} for the definition of element visibility.
7811 *
7812 * @defaultValue `false`
7813 */
7814 visible?: boolean;
7815 /**
7816 * Wait for the selected element to not be found in the DOM or to be hidden.
7817 * See {@link ElementHandle.isHidden} for the definition of element
7818 * invisibility.
7819 *
7820 * @defaultValue `false`
7821 */
7822 hidden?: boolean;
7823 /**
7824 * Maximum time to wait in milliseconds. Pass `0` to disable timeout.
7825 *
7826 * The default value can be changed by using {@link Page.setDefaultTimeout}
7827 *
7828 * @defaultValue `30_000` (30 seconds)
7829 */
7830 timeout?: number;
7831 /**
7832 * A signal object that allows you to cancel a waitForSelector call.
7833 */
7834 signal?: AbortSignal;
7835}
7836
7837/**
7838 * @public
7839 */
7840export declare interface WaitForTargetOptions {
7841 /**
7842 * Maximum wait time in milliseconds. Pass `0` to disable the timeout.
7843 *
7844 * @defaultValue `30_000`
7845 */
7846 timeout?: number;
7847 /**
7848 * A signal object that allows you to cancel a waitFor call.
7849 */
7850 signal?: AbortSignal;
7851}
7852
7853/* Excluded from this release type: WaitTask */
7854
7855/* Excluded from this release type: WaitTaskOptions */
7856
7857/**
7858 * @public
7859 */
7860export declare interface WaitTimeoutOptions {
7861 /**
7862 * Maximum wait time in milliseconds. Pass 0 to disable the timeout.
7863 *
7864 * The default value can be changed by using the
7865 * {@link Page.setDefaultTimeout} method.
7866 *
7867 * @defaultValue `30_000`
7868 */
7869 timeout?: number;
7870 /**
7871 * A signal object that allows you to cancel a waitFor call.
7872 */
7873 signal?: AbortSignal;
7874}
7875
7876/* Excluded from this release type: WEB_PERMISSION_TO_PROTOCOL_PERMISSION */
7877
7878/**
7879 * This class represents a
7880 * {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API | WebWorker}.
7881 *
7882 * @remarks
7883 * The events `workercreated` and `workerdestroyed` are emitted on the page
7884 * object to signal the worker lifecycle.
7885 *
7886 * @example
7887 *
7888 * ```ts
7889 * page.on('workercreated', worker =>
7890 * console.log('Worker created: ' + worker.url())
7891 * );
7892 * page.on('workerdestroyed', worker =>
7893 * console.log('Worker destroyed: ' + worker.url())
7894 * );
7895 *
7896 * console.log('Current workers:');
7897 * for (const worker of page.workers()) {
7898 * console.log(' ' + worker.url());
7899 * }
7900 * ```
7901 *
7902 * @public
7903 */
7904export declare abstract class WebWorker extends EventEmitter<Record<EventType, unknown>> {
7905 #private;
7906 /* Excluded from this release type: timeoutSettings */
7907 /* Excluded from this release type: __constructor */
7908 /* Excluded from this release type: mainRealm */
7909 /**
7910 * The URL of this web worker.
7911 */
7912 url(): string;
7913 /**
7914 * The CDP session client the WebWorker belongs to.
7915 */
7916 abstract get client(): CDPSession;
7917 /**
7918 * Evaluates a given function in the {@link WebWorker | worker}.
7919 *
7920 * @remarks If the given function returns a promise,
7921 * {@link WebWorker.evaluate | evaluate} will wait for the promise to resolve.
7922 *
7923 * As a rule of thumb, if the return value of the given function is more
7924 * complicated than a JSON object (e.g. most classes), then
7925 * {@link WebWorker.evaluate | evaluate} will _likely_ return some truncated
7926 * value (or `{}`). This is because we are not returning the actual return
7927 * value, but a deserialized version as a result of transferring the return
7928 * value through a protocol to Puppeteer.
7929 *
7930 * In general, you should use
7931 * {@link WebWorker.evaluateHandle | evaluateHandle} if
7932 * {@link WebWorker.evaluate | evaluate} cannot serialize the return value
7933 * properly or you need a mutable {@link JSHandle | handle} to the return
7934 * object.
7935 *
7936 * @param func - Function to be evaluated.
7937 * @param args - Arguments to pass into `func`.
7938 * @returns The result of `func`.
7939 */
7940 evaluate<Params extends unknown[], Func extends EvaluateFunc<Params> = EvaluateFunc<Params>>(func: Func | string, ...args: Params): Promise<Awaited<ReturnType<Func>>>;
7941 /**
7942 * Evaluates a given function in the {@link WebWorker | worker}.
7943 *
7944 * @remarks If the given function returns a promise,
7945 * {@link WebWorker.evaluate | evaluate} will wait for the promise to resolve.
7946 *
7947 * In general, you should use
7948 * {@link WebWorker.evaluateHandle | evaluateHandle} if
7949 * {@link WebWorker.evaluate | evaluate} cannot serialize the return value
7950 * properly or you need a mutable {@link JSHandle | handle} to the return
7951 * object.
7952 *
7953 * @param func - Function to be evaluated.
7954 * @param args - Arguments to pass into `func`.
7955 * @returns A {@link JSHandle | handle} to the return value of `func`.
7956 */
7957 evaluateHandle<Params extends unknown[], Func extends EvaluateFunc<Params> = EvaluateFunc<Params>>(func: Func | string, ...args: Params): Promise<HandleFor<Awaited<ReturnType<Func>>>>;
7958 close(): Promise<void>;
7959}
7960
7961/* Excluded from this release type: withSourcePuppeteerURLIfNone */
7962
7963/* Excluded from this release type: WorkerTarget */
7964
7965/* Excluded from this release type: XPathQueryHandler */
7966
7967export { }
7968
\No newline at end of file