Socket
Socket
Sign inDemoInstall

puppeteer-core

Package Overview
Dependencies
92
Maintainers
2
Versions
217
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 22.6.3 to 22.6.4

2

lib/cjs/puppeteer/api/Browser.d.ts

@@ -132,3 +132,3 @@ /**

*
* {@link Browser} {@link EventEmitter | emits} various events which are
* {@link Browser} {@link EventEmitter.emit | emits} various events which are
* documented in the {@link BrowserEvent} enum.

@@ -135,0 +135,0 @@ *

@@ -45,3 +45,3 @@ "use strict";

*
* {@link Browser} {@link EventEmitter | emits} various events which are
* {@link Browser} {@link EventEmitter.emit | emits} various events which are
* documented in the {@link BrowserEvent} enum.

@@ -48,0 +48,0 @@ *

@@ -117,3 +117,3 @@ /**

* {@link Browser.defaultBrowserContext | default browser context} can also be
* "icognito" if configured via the arguments and in such cases this getter
* "incognito" if configured via the arguments and in such cases this getter
* returns wrong results (see

@@ -120,0 +120,0 @@ * https://github.com/puppeteer/puppeteer/issues/8836). Also, the term

@@ -341,3 +341,3 @@ /**

* This method scrolls element into view if needed, and then
* uses {@link Page} to hover over the center of the element.
* uses {@link Page.mouse} to hover over the center of the element.
* If the element is detached from DOM, the method throws an error.

@@ -348,3 +348,3 @@ */

* This method scrolls element into view if needed, and then
* uses {@link Page | Page.mouse} to click in the center of the element.
* uses {@link Page.mouse} to click in the center of the element.
* If the element is detached from DOM, the method throws an error.

@@ -351,0 +351,0 @@ */

@@ -595,3 +595,3 @@ "use strict";

* This method scrolls element into view if needed, and then
* uses {@link Page} to hover over the center of the element.
* uses {@link Page.mouse} to hover over the center of the element.
* If the element is detached from DOM, the method throws an error.

@@ -606,3 +606,3 @@ */

* This method scrolls element into view if needed, and then
* uses {@link Page | Page.mouse} to click in the center of the element.
* uses {@link Page.mouse} to click in the center of the element.
* If the element is detached from DOM, the method throws an error.

@@ -609,0 +609,0 @@ */

@@ -1124,3 +1124,3 @@ "use strict";

* This method fetches an element with `selector`, scrolls it into view if
* needed, and then uses {@link Page | Page.mouse} to click in the center of the
* needed, and then uses {@link Page.mouse} to click in the center of the
* element. If there's no element matching `selector`, the method throws an

@@ -1174,3 +1174,3 @@ * error.

* This method fetches an element with `selector`, scrolls it into view if
* needed, and then uses {@link Page | Page.mouse}
* needed, and then uses {@link Page.mouse}
* to hover over the center of the element.

@@ -1222,3 +1222,3 @@ * If there's no element matching `selector`, the method throws an error.

* This method fetches an element with `selector`, scrolls it into view if
* needed, and then uses {@link Page | Page.touchscreen}
* needed, and then uses {@link Page.touchscreen}
* to tap in the center of the element.

@@ -1225,0 +1225,0 @@ * If there's no element matching `selector`, the method throws an error.

@@ -121,3 +121,2 @@ "use strict";

}
// keep-sorted start
#closed = (__runInitializers(this, _instanceExtraInitializers), false);

@@ -129,8 +128,5 @@ #reason;

#sharedWorkers = new Map();
// keep-sorted end
constructor(session) {
super();
// keep-sorted start
this.session = session;
// keep-sorted end
}

@@ -200,3 +196,2 @@ async #initialize() {

}
// keep-sorted start block=yes
get closed() {

@@ -218,3 +213,2 @@ return this.#closed;

}
// keep-sorted end
dispose(reason, closed = false) {

@@ -221,0 +215,0 @@ this.#closed = closed;

@@ -115,3 +115,2 @@ "use strict";

}
// keep-sorted start
#navigation = (__runInitializers(this, _instanceExtraInitializers), void 0);

@@ -128,6 +127,4 @@ #reason;

userContext;
// keep-sorted end
constructor(context, parent, id, url) {
super();
// keep-sorted start
this.#url = url;

@@ -137,3 +134,2 @@ this.id = id;

this.userContext = context;
// keep-sorted end
this.defaultRealm = this.#createWindowRealm();

@@ -232,3 +228,2 @@ }

}
// keep-sorted start block=yes
get #session() {

@@ -264,3 +259,2 @@ return this.userContext.browser.session;

}
// keep-sorted end
#createWindowRealm(sandbox) {

@@ -267,0 +261,0 @@ const realm = Realm_js_1.WindowRealm.from(this, sandbox);

@@ -154,2 +154,6 @@ /**

};
'network.continueWithAuth': {
params: Bidi.Network.ContinueWithAuthParameters;
returnType: Bidi.EmptyResult;
};
'network.failRequest': {

@@ -156,0 +160,0 @@ params: Bidi.Network.FailRequestParameters;

@@ -65,3 +65,2 @@ "use strict";

}
// keep-sorted start
#request = (__runInitializers(this, _instanceExtraInitializers), void 0);

@@ -72,8 +71,5 @@ #navigation;

#id;
// keep-sorted end
constructor(context) {
super();
// keep-sorted start
this.#browsingContext = context;
// keep-sorted end
}

@@ -154,3 +150,2 @@ #initialize() {

}
// keep-sorted start block=yes
get #session() {

@@ -168,3 +163,2 @@ return this.#browsingContext.userContext.browser.session;

}
// keep-sorted end
dispose() {

@@ -171,0 +165,0 @@ this[disposable_js_1.disposeSymbol]();

@@ -68,3 +68,2 @@ "use strict";

}
// keep-sorted start
#reason = (__runInitializers(this, _instanceExtraInitializers), void 0);

@@ -75,11 +74,7 @@ disposables = new disposable_js_1.DisposableStack();

executionContextId;
// keep-sorted end
constructor(id, origin) {
super();
// keep-sorted start
this.id = id;
this.origin = origin;
// keep-sorted end
}
// keep-sorted start block=yes
get disposed() {

@@ -91,3 +86,2 @@ return this.#reason !== undefined;

}
// keep-sorted end
dispose(reason) {

@@ -159,13 +153,9 @@ this.#reason = reason;

}
// keep-sorted start
browsingContext;
sandbox;
// keep-sorted end
#workers = new Map();
constructor(context, sandbox) {
super('', '');
// keep-sorted start
this.browsingContext = context;
this.sandbox = sandbox;
// keep-sorted end
}

@@ -223,6 +213,4 @@ #initialize() {

}
// keep-sorted start
#workers = new Map();
owners;
// keep-sorted end
constructor(owner, id, origin) {

@@ -272,6 +260,4 @@ super(id, origin);

}
// keep-sorted start
#workers = new Map();
browser;
// keep-sorted end
constructor(browser, id, origin) {

@@ -278,0 +264,0 @@ super(id, origin);

@@ -17,2 +17,4 @@ /**

/** Emitted when the request succeeds. */
authenticate: void;
/** Emitted when the request succeeds. */
success: Bidi.Network.ResponseData;

@@ -40,2 +42,3 @@ /** Emitted when the request fails. */

provideResponse({ statusCode, reasonPhrase, headers, body, }: Omit<Bidi.Network.ProvideResponseParameters, 'request'>): Promise<void>;
continueWithAuth(parameters: Bidi.Network.ContinueWithAuthCredentials | Bidi.Network.ContinueWithAuthNoCredentials): Promise<void>;
private dispose;

@@ -42,0 +45,0 @@ [disposeSymbol](): void;

@@ -65,3 +65,2 @@ "use strict";

}
// keep-sorted start
#error = (__runInitializers(this, _instanceExtraInitializers), void 0);

@@ -73,9 +72,6 @@ #redirect;

#event;
// keep-sorted end
constructor(browsingContext, event) {
super();
// keep-sorted start
this.#browsingContext = browsingContext;
this.#event = event;
// keep-sorted end
}

@@ -100,2 +96,11 @@ #initialize() {

});
sessionEmitter.on('network.authRequired', event => {
if (event.context !== this.#browsingContext.id ||
event.request.request !== this.id ||
// Don't try to authenticate for events that are not blocked
!event.isBlocked) {
return;
}
this.emit('authenticate', undefined);
});
sessionEmitter.on('network.fetchError', event => {

@@ -126,3 +131,2 @@ if (event.context !== this.#browsingContext.id ||

}
// keep-sorted start block=yes
get #session() {

@@ -174,3 +178,2 @@ return this.#browsingContext.userContext.browser.session;

}
// keep-sorted end
async continueRequest({ url, method, headers, cookies, body, }) {

@@ -200,2 +203,17 @@ await this.#session.send('network.continueRequest', {

}
async continueWithAuth(parameters) {
if (parameters.action === 'provideCredentials') {
await this.#session.send('network.continueWithAuth', {
request: this.id,
action: parameters.action,
credentials: parameters.credentials,
});
}
else {
await this.#session.send('network.continueWithAuth', {
request: this.id,
action: parameters.action,
});
}
}
dispose() {

@@ -202,0 +220,0 @@ this[disposable_js_1.disposeSymbol]();

@@ -119,3 +119,2 @@ "use strict";

}
// keep-sorted start
#reason = (__runInitializers(this, _instanceExtraInitializers), void 0);

@@ -128,9 +127,6 @@ #disposables = new disposable_js_1.DisposableStack();

set connection(value) { this.#connection_accessor_storage = value; }
// keep-sorted end
constructor(connection, info) {
super();
// keep-sorted start
this.#info = info;
this.connection = connection;
// keep-sorted end
}

@@ -157,3 +153,2 @@ async #initialize() {

}
// keep-sorted start block=yes
get capabilities() {

@@ -171,3 +166,2 @@ return this.#info.capabilities;

}
// keep-sorted end
dispose(reason) {

@@ -174,0 +168,0 @@ this.#reason = reason;

@@ -77,3 +77,2 @@ "use strict";

}
// keep-sorted start
#reason = (__runInitializers(this, _instanceExtraInitializers), void 0);

@@ -85,9 +84,6 @@ // Note these are only top-level contexts.

browser;
// keep-sorted end
constructor(browser, id) {
super();
// keep-sorted start
this.#id = id;
this.browser = browser;
// keep-sorted end
}

@@ -117,3 +113,2 @@ #initialize() {

}
// keep-sorted start block=yes
get #session() {

@@ -134,3 +129,2 @@ return this.browser.session;

}
// keep-sorted end
dispose(reason) {

@@ -137,0 +131,0 @@ this.#reason = reason;

@@ -66,3 +66,2 @@ "use strict";

}
// keep-sorted start
#reason = (__runInitializers(this, _instanceExtraInitializers), void 0);

@@ -73,9 +72,6 @@ #result;

info;
// keep-sorted end
constructor(context, info) {
super();
// keep-sorted start
this.browsingContext = context;
this.info = info;
// keep-sorted end
}

@@ -97,3 +93,2 @@ #initialize() {

}
// keep-sorted start block=yes
get #session() {

@@ -114,3 +109,2 @@ return this.browsingContext.userContext.browser.session;

}
// keep-sorted end
dispose(reason) {

@@ -117,0 +111,0 @@ this.#reason = reason;

@@ -76,2 +76,3 @@ "use strict";

const util_js_1 = require("../common/util.js");
const ErrorLike_js_1 = require("../util/ErrorLike.js");
const CDPSession_js_1 = require("./CDPSession.js");

@@ -208,3 +209,2 @@ const Deserializer_js_1 = require("./Deserializer.js");

request.once('success', () => {
// SAFETY: BidiHTTPRequest will create this before here.
this.page().trustedEmitter.emit("requestfinished" /* PageEvent.RequestFinished */, httpRequest);

@@ -347,3 +347,11 @@ });

// Related: https://bugzilla.mozilla.org/show_bug.cgi?id=1846601
this.browsingContext.navigate(url, "interactive" /* Bidi.BrowsingContext.ReadinessState.Interactive */),
this.browsingContext
.navigate(url, "interactive" /* Bidi.BrowsingContext.ReadinessState.Interactive */)
.catch(error => {
if ((0, ErrorLike_js_1.isErrorLike)(error) &&
error.message.includes('net::ERR_HTTP_RESPONSE_CODE_FAILURE')) {
return;
}
throw error;
}),
]).catch((0, util_js_2.rewriteNavigationError)(url, options.timeout ?? this.timeoutSettings.navigationTimeout()));

@@ -373,5 +381,3 @@ return response;

return (0, rxjs_js_1.combineLatest)(frames);
}), (0, rxjs_js_1.raceWith)((0, util_js_1.fromEmitterEvent)(navigation, 'fragment'), (0, util_js_1.fromEmitterEvent)(navigation, 'failed').pipe((0, rxjs_js_1.map)(({ url }) => {
throw new Error(`Navigation failed: ${url}`);
})), (0, util_js_1.fromEmitterEvent)(navigation, 'aborted').pipe((0, rxjs_js_1.map)(({ url }) => {
}), (0, rxjs_js_1.raceWith)((0, util_js_1.fromEmitterEvent)(navigation, 'fragment'), (0, util_js_1.fromEmitterEvent)(navigation, 'failed'), (0, util_js_1.fromEmitterEvent)(navigation, 'aborted').pipe((0, rxjs_js_1.map)(({ url }) => {
throw new Error(`Navigation aborted: ${url}`);

@@ -378,0 +384,0 @@ }))), (0, rxjs_js_1.switchMap)(() => {

@@ -43,2 +43,3 @@ "use strict";

});
this.#request.on('authenticate', this.#handleAuthentication);
this.#frame?.page().trustedEmitter.emit("request" /* PageEvent.Request */, this);

@@ -176,2 +177,25 @@ }

}
#authenticationHandled = false;
#handleAuthentication = async () => {
if (!this.#frame) {
return;
}
const credentials = this.#frame.page()._credentials;
if (credentials && !this.#authenticationHandled) {
this.#authenticationHandled = true;
void this.#request.continueWithAuth({
action: 'provideCredentials',
credentials: {
type: 'password',
username: credentials.username,
password: credentials.password,
},
});
}
else {
void this.#request.continueWithAuth({
action: 'cancel',
});
}
};
}

@@ -178,0 +202,0 @@ exports.BidiHTTPRequest = BidiHTTPRequest;

@@ -11,3 +11,3 @@ /**

import type { HTTPResponse } from '../api/HTTPResponse.js';
import type { GeolocationOptions, MediaFeature, PageEvents } from '../api/Page.js';
import type { Credentials, GeolocationOptions, MediaFeature, PageEvents } from '../api/Page.js';
import { Page, type NewDocumentScriptEvaluation, type ScreenshotOptions } from '../api/Page.js';

@@ -94,2 +94,7 @@ import { Accessibility } from '../cdp/Accessibility.js';

setRequestInterception(enable: boolean): Promise<void>;
/**
* @internal
*/
_credentials: Credentials | null;
authenticate(credentials: Credentials | null): Promise<void>;
setDragInterception(): never;

@@ -102,3 +107,2 @@ setBypassServiceWorker(): never;

removeExposedFunction(name: string): Promise<void>;
authenticate(): never;
setExtraHTTPHeaders(): never;

@@ -105,0 +109,0 @@ metrics(): never;

@@ -453,6 +453,3 @@ "use strict";

this.#interception = await this.#frame.browsingContext.addIntercept({
phases: [
"beforeRequestSent" /* Bidi.Network.InterceptPhase.BeforeRequestSent */,
"authRequired" /* Bidi.Network.InterceptPhase.AuthRequired */,
],
phases: ["beforeRequestSent" /* Bidi.Network.InterceptPhase.BeforeRequestSent */],
});

@@ -465,2 +462,19 @@ }

}
/**
* @internal
*/
_credentials = null;
#authInterception;
async authenticate(credentials) {
if (credentials && !this.#authInterception) {
this.#authInterception = await this.#frame.browsingContext.addIntercept({
phases: ["authRequired" /* Bidi.Network.InterceptPhase.AuthRequired */],
});
}
else if (!credentials && this.#authInterception) {
await this.#frame.browsingContext.userContext.browser.removeIntercept(this.#authInterception);
this.#authInterception = undefined;
}
this._credentials = credentials;
}
setDragInterception() {

@@ -539,5 +553,2 @@ throw new Errors_js_1.UnsupportedOperation();

}
authenticate() {
throw new Errors_js_1.UnsupportedOperation();
}
setExtraHTTPHeaders() {

@@ -544,0 +555,0 @@ throw new Errors_js_1.UnsupportedOperation();

@@ -20,3 +20,12 @@ "use strict";

return nodes.filter((node) => {
return !node.role || !NON_ELEMENT_NODE_ROLES.has(node.role.value);
if (node.ignored) {
return false;
}
if (!node.role) {
return false;
}
if (NON_ELEMENT_NODE_ROLES.has(node.role.value)) {
return false;
}
return true;
});

@@ -23,0 +32,0 @@ };

@@ -24,2 +24,3 @@ "use strict";

#mainFrame;
#isMainFrameStale = false;
#waitRequests = new Map();

@@ -58,4 +59,5 @@ getMainFrame() {

}
else if (!this.#mainFrame) {
else if (!this.#mainFrame || this.#isMainFrameStale) {
this.#mainFrame = frame;
this.#isMainFrameStale = false;
}

@@ -73,3 +75,3 @@ this.#waitRequests.get(frame._id)?.forEach(request => {

else {
this.#mainFrame = undefined;
this.#isMainFrameStale = true;
}

@@ -76,0 +78,0 @@ }

@@ -9,2 +9,3 @@ /**

import type { Frame } from '../api/Frame.js';
import type { Credentials } from '../api/Page.js';
import { EventEmitter } from '../common/EventEmitter.js';

@@ -15,9 +16,2 @@ import { type NetworkManagerEvents } from '../common/NetworkManagerEvents.js';

*/
export interface Credentials {
username: string;
password: string;
}
/**
* @public
*/
export interface NetworkConditions {

@@ -24,0 +18,0 @@ /**

@@ -14,2 +14,3 @@ /**

import type { JSHandle } from '../api/JSHandle.js';
import type { Credentials } from '../api/Page.js';
import { Page, type GeolocationOptions, type MediaFeature, type Metrics, type NewDocumentScriptEvaluation, type ScreenshotOptions, type WaitTimeoutOptions } from '../api/Page.js';

@@ -25,3 +26,3 @@ import type { Cookie, DeleteCookiesRequest, CookieParam } from '../common/Cookie.js';

import { CdpKeyboard, CdpMouse, CdpTouchscreen } from './Input.js';
import type { Credentials, NetworkConditions } from './NetworkManager.js';
import type { NetworkConditions } from './NetworkManager.js';
import type { CdpTarget } from './Target.js';

@@ -28,0 +29,0 @@ import { Tracing } from './Tracing.js';

@@ -83,3 +83,3 @@ /**

* HTML template for the print footer. Has the same constraints and support
* for special classes as {@link PDFOptions | PDFOptions.headerTemplate}.
* for special classes as {@link PDFOptions.headerTemplate}.
*/

@@ -86,0 +86,0 @@ footerTemplate?: string;

/**
* @internal
*/
export declare const packageVersion = "22.6.3";
export declare const packageVersion = "22.6.4";
//# sourceMappingURL=version.d.ts.map

@@ -7,3 +7,3 @@ "use strict";

*/
exports.packageVersion = '22.6.3';
exports.packageVersion = '22.6.4';
//# sourceMappingURL=version.js.map

@@ -30,3 +30,3 @@ /**

customQuerySelectors: {
"__#52523@#selectors": Map<string, CustomQuerySelectors.CustomQuerySelector>;
"__#52562@#selectors": Map<string, CustomQuerySelectors.CustomQuerySelector>;
register(name: string, handler: import("../puppeteer-core.js").CustomQueryHandler): void;

@@ -33,0 +33,0 @@ unregister(name: string): void;

@@ -82,7 +82,7 @@ /**

* When using with `puppeteer-core`,
* {@link LaunchOptions | options.executablePath} or
* {@link LaunchOptions | options.channel} must be provided.
* {@link LaunchOptions.executablePath | options.executablePath} or
* {@link LaunchOptions.channel | options.channel} must be provided.
*
* @example
* You can use {@link LaunchOptions | options.ignoreDefaultArgs}
* You can use {@link LaunchOptions.ignoreDefaultArgs | options.ignoreDefaultArgs}
* to filter out `--mute-audio` from default arguments:

@@ -89,0 +89,0 @@ *

@@ -98,7 +98,7 @@ "use strict";

* When using with `puppeteer-core`,
* {@link LaunchOptions | options.executablePath} or
* {@link LaunchOptions | options.channel} must be provided.
* {@link LaunchOptions.executablePath | options.executablePath} or
* {@link LaunchOptions.channel | options.channel} must be provided.
*
* @example
* You can use {@link LaunchOptions | options.ignoreDefaultArgs}
* You can use {@link LaunchOptions.ignoreDefaultArgs | options.ignoreDefaultArgs}
* to filter out `--mute-audio` from default arguments:

@@ -105,0 +105,0 @@ *

@@ -10,6 +10,6 @@ /**

export declare const PUPPETEER_REVISIONS: Readonly<{
chrome: "123.0.6312.105";
'chrome-headless-shell': "123.0.6312.105";
chrome: "123.0.6312.122";
'chrome-headless-shell': "123.0.6312.122";
firefox: "latest";
}>;
//# sourceMappingURL=revisions.d.ts.map

@@ -13,6 +13,6 @@ "use strict";

exports.PUPPETEER_REVISIONS = Object.freeze({
chrome: '123.0.6312.105',
'chrome-headless-shell': '123.0.6312.105',
chrome: '123.0.6312.122',
'chrome-headless-shell': '123.0.6312.122',
firefox: 'latest',
});
//# sourceMappingURL=revisions.js.map

@@ -71,3 +71,3 @@ "use strict";

value = value.replace(new RegExp(`PLACEHOLDER\\(\\s*(?:'${name}'|"${name}")\\s*\\)`, 'g'),
// Wrapping this ensures tersers that accidently inline PLACEHOLDER calls
// Wrapping this ensures tersers that accidentally inline PLACEHOLDER calls
// are still valid. Without, we may get calls like ()=>{...}() which is

@@ -74,0 +74,0 @@ // not valid.

@@ -9,3 +9,3 @@ import { disposeSymbol } from './disposable.js';

new (mutex: Mutex): {
"__#52513@#mutex": Mutex;
"__#52552@#mutex": Mutex;
[Symbol.dispose](): void;

@@ -12,0 +12,0 @@ };

@@ -132,3 +132,3 @@ /**

*
* {@link Browser} {@link EventEmitter | emits} various events which are
* {@link Browser} {@link EventEmitter.emit | emits} various events which are
* documented in the {@link BrowserEvent} enum.

@@ -135,0 +135,0 @@ *

@@ -42,3 +42,3 @@ /**

*
* {@link Browser} {@link EventEmitter | emits} various events which are
* {@link Browser} {@link EventEmitter.emit | emits} various events which are
* documented in the {@link BrowserEvent} enum.

@@ -45,0 +45,0 @@ *

@@ -117,3 +117,3 @@ /**

* {@link Browser.defaultBrowserContext | default browser context} can also be
* "icognito" if configured via the arguments and in such cases this getter
* "incognito" if configured via the arguments and in such cases this getter
* returns wrong results (see

@@ -120,0 +120,0 @@ * https://github.com/puppeteer/puppeteer/issues/8836). Also, the term

@@ -341,3 +341,3 @@ /**

* This method scrolls element into view if needed, and then
* uses {@link Page} to hover over the center of the element.
* uses {@link Page.mouse} to hover over the center of the element.
* If the element is detached from DOM, the method throws an error.

@@ -348,3 +348,3 @@ */

* This method scrolls element into view if needed, and then
* uses {@link Page | Page.mouse} to click in the center of the element.
* uses {@link Page.mouse} to click in the center of the element.
* If the element is detached from DOM, the method throws an error.

@@ -351,0 +351,0 @@ */

@@ -592,3 +592,3 @@ /**

* This method scrolls element into view if needed, and then
* uses {@link Page} to hover over the center of the element.
* uses {@link Page.mouse} to hover over the center of the element.
* If the element is detached from DOM, the method throws an error.

@@ -603,3 +603,3 @@ */

* This method scrolls element into view if needed, and then
* uses {@link Page | Page.mouse} to click in the center of the element.
* uses {@link Page.mouse} to click in the center of the element.
* If the element is detached from DOM, the method throws an error.

@@ -606,0 +606,0 @@ */

@@ -1097,3 +1097,3 @@ /**

* This method fetches an element with `selector`, scrolls it into view if
* needed, and then uses {@link Page | Page.mouse} to click in the center of the
* needed, and then uses {@link Page.mouse} to click in the center of the
* element. If there's no element matching `selector`, the method throws an

@@ -1147,3 +1147,3 @@ * error.

* This method fetches an element with `selector`, scrolls it into view if
* needed, and then uses {@link Page | Page.mouse}
* needed, and then uses {@link Page.mouse}
* to hover over the center of the element.

@@ -1195,3 +1195,3 @@ * If there's no element matching `selector`, the method throws an error.

* This method fetches an element with `selector`, scrolls it into view if
* needed, and then uses {@link Page | Page.touchscreen}
* needed, and then uses {@link Page.touchscreen}
* to tap in the center of the element.

@@ -1198,0 +1198,0 @@ * If there's no element matching `selector`, the method throws an error.

@@ -118,3 +118,2 @@ /**

}
// keep-sorted start
#closed = (__runInitializers(this, _instanceExtraInitializers), false);

@@ -126,8 +125,5 @@ #reason;

#sharedWorkers = new Map();
// keep-sorted end
constructor(session) {
super();
// keep-sorted start
this.session = session;
// keep-sorted end
}

@@ -197,3 +193,2 @@ async #initialize() {

}
// keep-sorted start block=yes
get closed() {

@@ -215,3 +210,2 @@ return this.#closed;

}
// keep-sorted end
dispose(reason, closed = false) {

@@ -218,0 +212,0 @@ this.#closed = closed;

@@ -112,3 +112,2 @@ /**

}
// keep-sorted start
#navigation = (__runInitializers(this, _instanceExtraInitializers), void 0);

@@ -125,6 +124,4 @@ #reason;

userContext;
// keep-sorted end
constructor(context, parent, id, url) {
super();
// keep-sorted start
this.#url = url;

@@ -134,3 +131,2 @@ this.id = id;

this.userContext = context;
// keep-sorted end
this.defaultRealm = this.#createWindowRealm();

@@ -229,3 +225,2 @@ }

}
// keep-sorted start block=yes
get #session() {

@@ -261,3 +256,2 @@ return this.userContext.browser.session;

}
// keep-sorted end
#createWindowRealm(sandbox) {

@@ -264,0 +258,0 @@ const realm = WindowRealm.from(this, sandbox);

@@ -154,2 +154,6 @@ /**

};
'network.continueWithAuth': {
params: Bidi.Network.ContinueWithAuthParameters;
returnType: Bidi.EmptyResult;
};
'network.failRequest': {

@@ -156,0 +160,0 @@ params: Bidi.Network.FailRequestParameters;

@@ -62,3 +62,2 @@ /**

}
// keep-sorted start
#request = (__runInitializers(this, _instanceExtraInitializers), void 0);

@@ -69,8 +68,5 @@ #navigation;

#id;
// keep-sorted end
constructor(context) {
super();
// keep-sorted start
this.#browsingContext = context;
// keep-sorted end
}

@@ -151,3 +147,2 @@ #initialize() {

}
// keep-sorted start block=yes
get #session() {

@@ -165,3 +160,2 @@ return this.#browsingContext.userContext.browser.session;

}
// keep-sorted end
dispose() {

@@ -168,0 +162,0 @@ this[disposeSymbol]();

@@ -65,3 +65,2 @@ /**

}
// keep-sorted start
#reason = (__runInitializers(this, _instanceExtraInitializers), void 0);

@@ -72,11 +71,7 @@ disposables = new DisposableStack();

executionContextId;
// keep-sorted end
constructor(id, origin) {
super();
// keep-sorted start
this.id = id;
this.origin = origin;
// keep-sorted end
}
// keep-sorted start block=yes
get disposed() {

@@ -88,3 +83,2 @@ return this.#reason !== undefined;

}
// keep-sorted end
dispose(reason) {

@@ -156,13 +150,9 @@ this.#reason = reason;

}
// keep-sorted start
browsingContext;
sandbox;
// keep-sorted end
#workers = new Map();
constructor(context, sandbox) {
super('', '');
// keep-sorted start
this.browsingContext = context;
this.sandbox = sandbox;
// keep-sorted end
}

@@ -219,6 +209,4 @@ #initialize() {

}
// keep-sorted start
#workers = new Map();
owners;
// keep-sorted end
constructor(owner, id, origin) {

@@ -267,6 +255,4 @@ super(id, origin);

}
// keep-sorted start
#workers = new Map();
browser;
// keep-sorted end
constructor(browser, id, origin) {

@@ -273,0 +259,0 @@ super(id, origin);

@@ -17,2 +17,4 @@ /**

/** Emitted when the request succeeds. */
authenticate: void;
/** Emitted when the request succeeds. */
success: Bidi.Network.ResponseData;

@@ -40,2 +42,3 @@ /** Emitted when the request fails. */

provideResponse({ statusCode, reasonPhrase, headers, body, }: Omit<Bidi.Network.ProvideResponseParameters, 'request'>): Promise<void>;
continueWithAuth(parameters: Bidi.Network.ContinueWithAuthCredentials | Bidi.Network.ContinueWithAuthNoCredentials): Promise<void>;
private dispose;

@@ -42,0 +45,0 @@ [disposeSymbol](): void;

@@ -62,3 +62,2 @@ /**

}
// keep-sorted start
#error = (__runInitializers(this, _instanceExtraInitializers), void 0);

@@ -70,9 +69,6 @@ #redirect;

#event;
// keep-sorted end
constructor(browsingContext, event) {
super();
// keep-sorted start
this.#browsingContext = browsingContext;
this.#event = event;
// keep-sorted end
}

@@ -97,2 +93,11 @@ #initialize() {

});
sessionEmitter.on('network.authRequired', event => {
if (event.context !== this.#browsingContext.id ||
event.request.request !== this.id ||
// Don't try to authenticate for events that are not blocked
!event.isBlocked) {
return;
}
this.emit('authenticate', undefined);
});
sessionEmitter.on('network.fetchError', event => {

@@ -123,3 +128,2 @@ if (event.context !== this.#browsingContext.id ||

}
// keep-sorted start block=yes
get #session() {

@@ -171,3 +175,2 @@ return this.#browsingContext.userContext.browser.session;

}
// keep-sorted end
async continueRequest({ url, method, headers, cookies, body, }) {

@@ -197,2 +200,17 @@ await this.#session.send('network.continueRequest', {

}
async continueWithAuth(parameters) {
if (parameters.action === 'provideCredentials') {
await this.#session.send('network.continueWithAuth', {
request: this.id,
action: parameters.action,
credentials: parameters.credentials,
});
}
else {
await this.#session.send('network.continueWithAuth', {
request: this.id,
action: parameters.action,
});
}
}
dispose() {

@@ -199,0 +217,0 @@ this[disposeSymbol]();

@@ -116,3 +116,2 @@ /**

}
// keep-sorted start
#reason = (__runInitializers(this, _instanceExtraInitializers), void 0);

@@ -125,9 +124,6 @@ #disposables = new DisposableStack();

set connection(value) { this.#connection_accessor_storage = value; }
// keep-sorted end
constructor(connection, info) {
super();
// keep-sorted start
this.#info = info;
this.connection = connection;
// keep-sorted end
}

@@ -154,3 +150,2 @@ async #initialize() {

}
// keep-sorted start block=yes
get capabilities() {

@@ -168,3 +163,2 @@ return this.#info.capabilities;

}
// keep-sorted end
dispose(reason) {

@@ -171,0 +165,0 @@ this.#reason = reason;

@@ -74,3 +74,2 @@ /**

}
// keep-sorted start
#reason = (__runInitializers(this, _instanceExtraInitializers), void 0);

@@ -82,9 +81,6 @@ // Note these are only top-level contexts.

browser;
// keep-sorted end
constructor(browser, id) {
super();
// keep-sorted start
this.#id = id;
this.browser = browser;
// keep-sorted end
}

@@ -114,3 +110,2 @@ #initialize() {

}
// keep-sorted start block=yes
get #session() {

@@ -131,3 +126,2 @@ return this.browser.session;

}
// keep-sorted end
dispose(reason) {

@@ -134,0 +128,0 @@ this.#reason = reason;

@@ -63,3 +63,2 @@ /**

}
// keep-sorted start
#reason = (__runInitializers(this, _instanceExtraInitializers), void 0);

@@ -70,9 +69,6 @@ #result;

info;
// keep-sorted end
constructor(context, info) {
super();
// keep-sorted start
this.browsingContext = context;
this.info = info;
// keep-sorted end
}

@@ -94,3 +90,2 @@ #initialize() {

}
// keep-sorted start block=yes
get #session() {

@@ -111,3 +106,2 @@ return this.browsingContext.userContext.browser.session;

}
// keep-sorted end
dispose(reason) {

@@ -114,0 +108,0 @@ this.#reason = reason;

@@ -50,2 +50,3 @@ /**

import { debugError, fromEmitterEvent, timeout } from '../common/util.js';
import { isErrorLike } from '../util/ErrorLike.js';
import { BidiCdpSession } from './CDPSession.js';

@@ -182,3 +183,2 @@ import { BidiDeserializer } from './Deserializer.js';

request.once('success', () => {
// SAFETY: BidiHTTPRequest will create this before here.
this.page().trustedEmitter.emit("requestfinished" /* PageEvent.RequestFinished */, httpRequest);

@@ -321,3 +321,11 @@ });

// Related: https://bugzilla.mozilla.org/show_bug.cgi?id=1846601
this.browsingContext.navigate(url, "interactive" /* Bidi.BrowsingContext.ReadinessState.Interactive */),
this.browsingContext
.navigate(url, "interactive" /* Bidi.BrowsingContext.ReadinessState.Interactive */)
.catch(error => {
if (isErrorLike(error) &&
error.message.includes('net::ERR_HTTP_RESPONSE_CODE_FAILURE')) {
return;
}
throw error;
}),
]).catch(rewriteNavigationError(url, options.timeout ?? this.timeoutSettings.navigationTimeout()));

@@ -347,5 +355,3 @@ return response;

return combineLatest(frames);
}), raceWith(fromEmitterEvent(navigation, 'fragment'), fromEmitterEvent(navigation, 'failed').pipe(map(({ url }) => {
throw new Error(`Navigation failed: ${url}`);
})), fromEmitterEvent(navigation, 'aborted').pipe(map(({ url }) => {
}), raceWith(fromEmitterEvent(navigation, 'fragment'), fromEmitterEvent(navigation, 'failed'), fromEmitterEvent(navigation, 'aborted').pipe(map(({ url }) => {
throw new Error(`Navigation aborted: ${url}`);

@@ -352,0 +358,0 @@ }))), switchMap(() => {

@@ -40,2 +40,3 @@ var _a;

});
this.#request.on('authenticate', this.#handleAuthentication);
this.#frame?.page().trustedEmitter.emit("request" /* PageEvent.Request */, this);

@@ -173,2 +174,25 @@ }

}
#authenticationHandled = false;
#handleAuthentication = async () => {
if (!this.#frame) {
return;
}
const credentials = this.#frame.page()._credentials;
if (credentials && !this.#authenticationHandled) {
this.#authenticationHandled = true;
void this.#request.continueWithAuth({
action: 'provideCredentials',
credentials: {
type: 'password',
username: credentials.username,
password: credentials.password,
},
});
}
else {
void this.#request.continueWithAuth({
action: 'cancel',
});
}
};
}

@@ -175,0 +199,0 @@ _a = BidiHTTPRequest;

@@ -11,3 +11,3 @@ /**

import type { HTTPResponse } from '../api/HTTPResponse.js';
import type { GeolocationOptions, MediaFeature, PageEvents } from '../api/Page.js';
import type { Credentials, GeolocationOptions, MediaFeature, PageEvents } from '../api/Page.js';
import { Page, type NewDocumentScriptEvaluation, type ScreenshotOptions } from '../api/Page.js';

@@ -94,2 +94,7 @@ import { Accessibility } from '../cdp/Accessibility.js';

setRequestInterception(enable: boolean): Promise<void>;
/**
* @internal
*/
_credentials: Credentials | null;
authenticate(credentials: Credentials | null): Promise<void>;
setDragInterception(): never;

@@ -102,3 +107,2 @@ setBypassServiceWorker(): never;

removeExposedFunction(name: string): Promise<void>;
authenticate(): never;
setExtraHTTPHeaders(): never;

@@ -105,0 +109,0 @@ metrics(): never;

@@ -450,6 +450,3 @@ /**

this.#interception = await this.#frame.browsingContext.addIntercept({
phases: [
"beforeRequestSent" /* Bidi.Network.InterceptPhase.BeforeRequestSent */,
"authRequired" /* Bidi.Network.InterceptPhase.AuthRequired */,
],
phases: ["beforeRequestSent" /* Bidi.Network.InterceptPhase.BeforeRequestSent */],
});

@@ -462,2 +459,19 @@ }

}
/**
* @internal
*/
_credentials = null;
#authInterception;
async authenticate(credentials) {
if (credentials && !this.#authInterception) {
this.#authInterception = await this.#frame.browsingContext.addIntercept({
phases: ["authRequired" /* Bidi.Network.InterceptPhase.AuthRequired */],
});
}
else if (!credentials && this.#authInterception) {
await this.#frame.browsingContext.userContext.browser.removeIntercept(this.#authInterception);
this.#authInterception = undefined;
}
this._credentials = credentials;
}
setDragInterception() {

@@ -536,5 +550,2 @@ throw new UnsupportedOperation();

}
authenticate() {
throw new UnsupportedOperation();
}
setExtraHTTPHeaders() {

@@ -541,0 +552,0 @@ throw new UnsupportedOperation();

@@ -17,3 +17,12 @@ /**

return nodes.filter((node) => {
return !node.role || !NON_ELEMENT_NODE_ROLES.has(node.role.value);
if (node.ignored) {
return false;
}
if (!node.role) {
return false;
}
if (NON_ELEMENT_NODE_ROLES.has(node.role.value)) {
return false;
}
return true;
});

@@ -20,0 +29,0 @@ };

@@ -21,2 +21,3 @@ /**

#mainFrame;
#isMainFrameStale = false;
#waitRequests = new Map();

@@ -55,4 +56,5 @@ getMainFrame() {

}
else if (!this.#mainFrame) {
else if (!this.#mainFrame || this.#isMainFrameStale) {
this.#mainFrame = frame;
this.#isMainFrameStale = false;
}

@@ -70,3 +72,3 @@ this.#waitRequests.get(frame._id)?.forEach(request => {

else {
this.#mainFrame = undefined;
this.#isMainFrameStale = true;
}

@@ -73,0 +75,0 @@ }

@@ -9,2 +9,3 @@ /**

import type { Frame } from '../api/Frame.js';
import type { Credentials } from '../api/Page.js';
import { EventEmitter } from '../common/EventEmitter.js';

@@ -15,9 +16,2 @@ import { type NetworkManagerEvents } from '../common/NetworkManagerEvents.js';

*/
export interface Credentials {
username: string;
password: string;
}
/**
* @public
*/
export interface NetworkConditions {

@@ -24,0 +18,0 @@ /**

@@ -14,2 +14,3 @@ /**

import type { JSHandle } from '../api/JSHandle.js';
import type { Credentials } from '../api/Page.js';
import { Page, type GeolocationOptions, type MediaFeature, type Metrics, type NewDocumentScriptEvaluation, type ScreenshotOptions, type WaitTimeoutOptions } from '../api/Page.js';

@@ -25,3 +26,3 @@ import type { Cookie, DeleteCookiesRequest, CookieParam } from '../common/Cookie.js';

import { CdpKeyboard, CdpMouse, CdpTouchscreen } from './Input.js';
import type { Credentials, NetworkConditions } from './NetworkManager.js';
import type { NetworkConditions } from './NetworkManager.js';
import type { CdpTarget } from './Target.js';

@@ -28,0 +29,0 @@ import { Tracing } from './Tracing.js';

@@ -83,3 +83,3 @@ /**

* HTML template for the print footer. Has the same constraints and support
* for special classes as {@link PDFOptions | PDFOptions.headerTemplate}.
* for special classes as {@link PDFOptions.headerTemplate}.
*/

@@ -86,0 +86,0 @@ footerTemplate?: string;

/**
* @internal
*/
export declare const packageVersion = "22.6.3";
export declare const packageVersion = "22.6.4";
//# sourceMappingURL=version.d.ts.map
/**
* @internal
*/
export const packageVersion = '22.6.3';
export const packageVersion = '22.6.4';
//# sourceMappingURL=version.js.map

@@ -82,7 +82,7 @@ /**

* When using with `puppeteer-core`,
* {@link LaunchOptions | options.executablePath} or
* {@link LaunchOptions | options.channel} must be provided.
* {@link LaunchOptions.executablePath | options.executablePath} or
* {@link LaunchOptions.channel | options.channel} must be provided.
*
* @example
* You can use {@link LaunchOptions | options.ignoreDefaultArgs}
* You can use {@link LaunchOptions.ignoreDefaultArgs | options.ignoreDefaultArgs}
* to filter out `--mute-audio` from default arguments:

@@ -89,0 +89,0 @@ *

@@ -95,7 +95,7 @@ /**

* When using with `puppeteer-core`,
* {@link LaunchOptions | options.executablePath} or
* {@link LaunchOptions | options.channel} must be provided.
* {@link LaunchOptions.executablePath | options.executablePath} or
* {@link LaunchOptions.channel | options.channel} must be provided.
*
* @example
* You can use {@link LaunchOptions | options.ignoreDefaultArgs}
* You can use {@link LaunchOptions.ignoreDefaultArgs | options.ignoreDefaultArgs}
* to filter out `--mute-audio` from default arguments:

@@ -102,0 +102,0 @@ *

@@ -10,6 +10,6 @@ /**

export declare const PUPPETEER_REVISIONS: Readonly<{
chrome: "123.0.6312.105";
'chrome-headless-shell': "123.0.6312.105";
chrome: "123.0.6312.122";
'chrome-headless-shell': "123.0.6312.122";
firefox: "latest";
}>;
//# sourceMappingURL=revisions.d.ts.map

@@ -10,6 +10,6 @@ /**

export const PUPPETEER_REVISIONS = Object.freeze({
chrome: '123.0.6312.105',
'chrome-headless-shell': '123.0.6312.105',
chrome: '123.0.6312.122',
'chrome-headless-shell': '123.0.6312.122',
firefox: 'latest',
});
//# sourceMappingURL=revisions.js.map

@@ -66,3 +66,3 @@ /**

value = value.replace(new RegExp(`PLACEHOLDER\\(\\s*(?:'${name}'|"${name}")\\s*\\)`, 'g'),
// Wrapping this ensures tersers that accidently inline PLACEHOLDER calls
// Wrapping this ensures tersers that accidentally inline PLACEHOLDER calls
// are still valid. Without, we may get calls like ()=>{...}() which is

@@ -69,0 +69,0 @@ // not valid.

{
"name": "puppeteer-core",
"version": "22.6.3",
"version": "22.6.4",
"description": "A high-level API to control headless Chrome over the DevTools Protocol",

@@ -123,3 +123,3 @@ "keywords": [

"@puppeteer/browsers": "2.2.1",
"chromium-bidi": "0.5.16",
"chromium-bidi": "0.5.17",
"debug": "4.3.4",

@@ -126,0 +126,0 @@ "devtools-protocol": "0.0.1262051",

@@ -8,139 +8,15 @@ # Puppeteer

#### [Guides](https://pptr.dev/category/guides) | [API](https://pptr.dev/api) | [FAQ](https://pptr.dev/faq) | [Contributing](https://pptr.dev/contributing) | [Troubleshooting](https://pptr.dev/troubleshooting)
#### [Docs](https://pptr.dev/docs) | [API](https://pptr.dev/api) | [FAQ](https://pptr.dev/faq) | [Contributing](https://pptr.dev/contributing) | [Troubleshooting](https://pptr.dev/troubleshooting)
> Puppeteer is a Node.js library which provides a high-level API to control
> Chrome/Chromium over the
> [DevTools Protocol](https://chromedevtools.github.io/devtools-protocol/).
> Puppeteer runs in
> [headless](https://developer.chrome.com/docs/chromium/new-headless/)
> mode by default, but can be configured to run in full ("headful")
> Chrome/Chromium.
Puppeteer is a Node.js library which provides a high-level API to control
Chrome/Chromium over the
[DevTools Protocol](https://chromedevtools.github.io/devtools-protocol/).
Puppeteer runs in
[headless](https://developer.chrome.com/docs/chromium/new-headless/)
mode by default, but can be configured to run in full ("headful")
Chrome/Chromium.
#### What can I do?
## Example
Most things that you can do manually in the browser can be done using Puppeteer!
Here are a few examples to get you started:
- Generate screenshots and PDFs of pages.
- Crawl a SPA (Single-Page Application) and generate pre-rendered content (i.e.
"SSR" (Server-Side Rendering)).
- Automate form submission, UI testing, keyboard input, etc.
- Create an automated testing environment using the latest JavaScript and
browser features.
- Capture a
[timeline trace](https://developer.chrome.com/docs/devtools/performance/reference)
of your site to help diagnose performance issues.
- [Test Chrome Extensions](https://pptr.dev/guides/chrome-extensions).
## Getting Started
### Installation
To use Puppeteer in your project, run:
```bash
npm i puppeteer
# or using yarn
yarn add puppeteer
# or using pnpm
pnpm i puppeteer
```
When you install Puppeteer, it automatically downloads a recent version of
[Chrome for Testing](https://developer.chrome.com/blog/chrome-for-testing/) (~170MB macOS, ~282MB Linux, ~280MB Windows) and a `chrome-headless-shell` binary (starting with Puppeteer v21.6.0) that is [guaranteed to
work](https://pptr.dev/faq#q-why-doesnt-puppeteer-vxxx-work-with-chromium-vyyy)
with Puppeteer. The browser is downloaded to the `$HOME/.cache/puppeteer` folder
by default (starting with Puppeteer v19.0.0). See [configuration](https://pptr.dev/api/puppeteer.configuration) for configuration options and environmental variables to control the download behavor.
If you deploy a project using Puppeteer to a hosting provider, such as Render or
Heroku, you might need to reconfigure the location of the cache to be within
your project folder (see an example below) because not all hosting providers
include `$HOME/.cache` into the project's deployment.
For a version of Puppeteer without the browser installation, see
[`puppeteer-core`](#puppeteer-core).
If used with TypeScript, the minimum supported TypeScript version is `4.7.4`.
#### Configuration
Puppeteer uses several defaults that can be customized through configuration
files.
For example, to change the default cache directory Puppeteer uses to install
browsers, you can add a `.puppeteerrc.cjs` (or `puppeteer.config.cjs`) at the
root of your application with the contents
```js
const {join} = require('path');
/**
* @type {import("puppeteer").Configuration}
*/
module.exports = {
// Changes the cache location for Puppeteer.
cacheDirectory: join(__dirname, '.cache', 'puppeteer'),
};
```
After adding the configuration file, you will need to remove and reinstall
`puppeteer` for it to take effect.
See the [configuration guide](https://pptr.dev/guides/configuration) for more
information.
#### `puppeteer-core`
For every release since v1.7.0 we publish two packages:
- [`puppeteer`](https://www.npmjs.com/package/puppeteer)
- [`puppeteer-core`](https://www.npmjs.com/package/puppeteer-core)
`puppeteer` is a _product_ for browser automation. When installed, it downloads
a version of Chrome, which it then drives using `puppeteer-core`. Being an
end-user product, `puppeteer` automates several workflows using reasonable
defaults [that can be customized](https://pptr.dev/guides/configuration).
`puppeteer-core` is a _library_ to help drive anything that supports DevTools
protocol. Being a library, `puppeteer-core` is fully driven through its
programmatic interface implying no defaults are assumed and `puppeteer-core`
will not download Chrome when installed.
You should use `puppeteer-core` if you are
[connecting to a remote browser](https://pptr.dev/api/puppeteer.puppeteer.connect)
or [managing browsers yourself](https://pptr.dev/browsers-api/).
If you are managing browsers yourself, you will need to call
[`puppeteer.launch`](https://pptr.dev/api/puppeteer.puppeteernode.launch) with
an explicit
[`executablePath`](https://pptr.dev/api/puppeteer.launchoptions)
(or [`channel`](https://pptr.dev/api/puppeteer.launchoptions) if it's
installed in a standard location).
When using `puppeteer-core`, remember to change the import:
```ts
import puppeteer from 'puppeteer-core';
```
### Usage
Puppeteer follows the latest
[maintenance LTS](https://github.com/nodejs/Release#release-schedule) version of
Node.
Puppeteer will be familiar to people using other browser testing frameworks. You
[launch](https://pptr.dev/api/puppeteer.puppeteernode.launch)/[connect](https://pptr.dev/api/puppeteer.puppeteernode.connect)
a [browser](https://pptr.dev/api/puppeteer.browser),
[create](https://pptr.dev/api/puppeteer.browser.newpage) some
[pages](https://pptr.dev/api/puppeteer.page), and then manipulate them with
[Puppeteer's API](https://pptr.dev/api).
For more in-depth usage, check our [guides](https://pptr.dev/category/guides)
and [examples](https://github.com/puppeteer/puppeteer/tree/main/examples).
#### Example
The following example searches [developer.chrome.com](https://developer.chrome.com/) for blog posts with text "automate beyond recorder", click on the first result and print the full title of the blog post.
```ts
import puppeteer from 'puppeteer';

@@ -180,84 +56,5 @@

### Default runtime settings
**1. Uses Headless mode**
By default Puppeteer launches Chrome in
[the Headless mode](https://developer.chrome.com/docs/chromium/new-headless/).
```ts
const browser = await puppeteer.launch();
// Equivalent to
const browser = await puppeteer.launch({headless: true});
```
Before v22, Puppeteer launched the [old Headless mode](https://developer.chrome.com/docs/chromium/new-headless/) by default.
The old headless mode is now known as
[`chrome-headless-shell`](https://developer.chrome.com/blog/chrome-headless-shell)
and ships as a separate binary. `chrome-headless-shell` does not match the
behavior of the regular Chrome completely but it is currently more performant
for automation tasks where the complete Chrome feature set is not needed. If the performance
is more important for your use case, switch to `chrome-headless-shell` as following:
```ts
const browser = await puppeteer.launch({headless: 'shell'});
```
To launch a "headful" version of Chrome, set the
[`headless`](https://pptr.dev/api/puppeteer.browserlaunchargumentoptions) to `false`
option when launching a browser:
```ts
const browser = await puppeteer.launch({headless: false});
```
**2. Runs a bundled version of Chrome**
By default, Puppeteer downloads and uses a specific version of Chrome so its
API is guaranteed to work out of the box. To use Puppeteer with a different
version of Chrome or Chromium, pass in the executable's path when creating a
`Browser` instance:
```ts
const browser = await puppeteer.launch({executablePath: '/path/to/Chrome'});
```
You can also use Puppeteer with Firefox. See
[status of cross-browser support](https://pptr.dev/faq#q-what-is-the-status-of-cross-browser-support) for
more information.
See
[`this article`](https://www.howtogeek.com/202825/what%E2%80%99s-the-difference-between-chromium-and-chrome/)
for a description of the differences between Chromium and Chrome.
[`This article`](https://chromium.googlesource.com/chromium/src/+/refs/heads/main/docs/chromium_browser_vs_google_chrome.md)
describes some differences for Linux users.
**3. Creates a fresh user profile**
Puppeteer creates its own browser user profile which it **cleans up on every
run**.
#### Using Docker
See our [Docker guide](https://pptr.dev/guides/docker).
#### Using Chrome Extensions
See our [Chrome extensions guide](https://pptr.dev/guides/chrome-extensions).
## Resources
- [API Documentation](https://pptr.dev/api)
- [Guides](https://pptr.dev/category/guides)
- [Examples](https://github.com/puppeteer/puppeteer/tree/main/examples)
- [Community list of Puppeteer resources](https://github.com/transitive-bullshit/awesome-puppeteer)
## Contributing
Check out our [contributing guide](https://pptr.dev/contributing) to get an
Check out our [contributing guide](https://pptr.dev/community/contributing) to get an
overview of Puppeteer development.
## FAQ
Our [FAQ](https://pptr.dev/faq) has migrated to
[our site](https://pptr.dev/faq).

@@ -200,3 +200,3 @@ /**

*
* {@link Browser} {@link EventEmitter | emits} various events which are
* {@link Browser} {@link EventEmitter.emit | emits} various events which are
* documented in the {@link BrowserEvent} enum.

@@ -203,0 +203,0 @@ *

@@ -154,3 +154,3 @@ /**

* {@link Browser.defaultBrowserContext | default browser context} can also be
* "icognito" if configured via the arguments and in such cases this getter
* "incognito" if configured via the arguments and in such cases this getter
* returns wrong results (see

@@ -157,0 +157,0 @@ * https://github.com/puppeteer/puppeteer/issues/8836). Also, the term

@@ -626,3 +626,3 @@ /**

* This method scrolls element into view if needed, and then
* uses {@link Page} to hover over the center of the element.
* uses {@link Page.mouse} to hover over the center of the element.
* If the element is detached from DOM, the method throws an error.

@@ -640,3 +640,3 @@ */

* This method scrolls element into view if needed, and then
* uses {@link Page | Page.mouse} to click in the center of the element.
* uses {@link Page.mouse} to click in the center of the element.
* If the element is detached from DOM, the method throws an error.

@@ -643,0 +643,0 @@ */

@@ -54,3 +54,2 @@ /**

// keep-sorted start
#closed = false;

@@ -62,9 +61,7 @@ #reason: string | undefined;

readonly #sharedWorkers = new Map<string, SharedWorkerRealm>();
// keep-sorted end
private constructor(session: Session) {
super();
// keep-sorted start
this.session = session;
// keep-sorted end
}

@@ -146,3 +143,2 @@

// keep-sorted start block=yes
get closed(): boolean {

@@ -164,3 +160,2 @@ return this.#closed;

}
// keep-sorted end

@@ -167,0 +162,0 @@ @inertIfDisposed

@@ -132,3 +132,2 @@ /**

// keep-sorted start
#navigation: Navigation | undefined;

@@ -145,3 +144,2 @@ #reason?: string;

readonly userContext: UserContext;
// keep-sorted end

@@ -155,3 +153,3 @@ private constructor(

super();
// keep-sorted start
this.#url = url;

@@ -161,3 +159,2 @@ this.id = id;

this.userContext = context;
// keep-sorted end

@@ -290,3 +287,2 @@ this.defaultRealm = this.#createWindowRealm();

// keep-sorted start block=yes
get #session() {

@@ -322,3 +318,2 @@ return this.userContext.browser.session;

}
// keep-sorted end

@@ -325,0 +320,0 @@ #createWindowRealm(sandbox?: string) {

@@ -165,2 +165,6 @@ /**

};
'network.continueWithAuth': {
params: Bidi.Network.ContinueWithAuthParameters;
returnType: Bidi.EmptyResult;
};
'network.failRequest': {

@@ -167,0 +171,0 @@ params: Bidi.Network.FailRequestParameters;

@@ -41,3 +41,2 @@ /**

// keep-sorted start
#request: Request | undefined;

@@ -48,9 +47,7 @@ #navigation: Navigation | undefined;

#id?: string | null;
// keep-sorted end
private constructor(context: BrowsingContext) {
super();
// keep-sorted start
this.#browsingContext = context;
// keep-sorted end
}

@@ -156,3 +153,2 @@

// keep-sorted start block=yes
get #session() {

@@ -170,3 +166,2 @@ return this.#browsingContext.userContext.browser.session;

}
// keep-sorted end

@@ -173,0 +168,0 @@ @inertIfDisposed

@@ -47,3 +47,2 @@ /**

}> {
// keep-sorted start
#reason?: string;

@@ -54,13 +53,10 @@ protected readonly disposables = new DisposableStack();

protected executionContextId?: number;
// keep-sorted end
protected constructor(id: string, origin: string) {
super();
// keep-sorted start
this.id = id;
this.origin = origin;
// keep-sorted end
}
// keep-sorted start block=yes
get disposed(): boolean {

@@ -73,3 +69,2 @@ return this.#reason !== undefined;

}
// keep-sorted end

@@ -165,6 +160,4 @@ @inertIfDisposed

// keep-sorted start
readonly browsingContext: BrowsingContext;
readonly sandbox?: string;
// keep-sorted end

@@ -175,6 +168,5 @@ readonly #workers = new Map<string, DedicatedWorkerRealm>();

super('', '');
// keep-sorted start
this.browsingContext = context;
this.sandbox = sandbox;
// keep-sorted end
}

@@ -256,6 +248,4 @@

// keep-sorted start
readonly #workers = new Map<string, DedicatedWorkerRealm>();
readonly owners: Set<DedicatedWorkerOwnerRealm>;
// keep-sorted end

@@ -315,6 +305,4 @@ private constructor(

// keep-sorted start
readonly #workers = new Map<string, DedicatedWorkerRealm>();
readonly browser: Browser;
// keep-sorted end

@@ -321,0 +309,0 @@ private constructor(browser: Browser, id: string, origin: string) {

@@ -22,2 +22,4 @@ /**

/** Emitted when the request succeeds. */
authenticate: void;
/** Emitted when the request succeeds. */
success: Bidi.Network.ResponseData;

@@ -36,3 +38,2 @@ /** Emitted when the request fails. */

// keep-sorted start
#error?: string;

@@ -44,3 +45,2 @@ #redirect?: Request;

readonly #event: Bidi.Network.BeforeRequestSentParameters;
// keep-sorted end

@@ -52,6 +52,5 @@ private constructor(

super();
// keep-sorted start
this.#browsingContext = browsingContext;
this.#event = event;
// keep-sorted end
}

@@ -84,2 +83,13 @@

});
sessionEmitter.on('network.authRequired', event => {
if (
event.context !== this.#browsingContext.id ||
event.request.request !== this.id ||
// Don't try to authenticate for events that are not blocked
!event.isBlocked
) {
return;
}
this.emit('authenticate', undefined);
});
sessionEmitter.on('network.fetchError', event => {

@@ -115,3 +125,2 @@ if (

// keep-sorted start block=yes
get #session() {

@@ -163,3 +172,2 @@ return this.#browsingContext.userContext.browser.session;

}
// keep-sorted end

@@ -204,2 +212,21 @@ async continueRequest({

async continueWithAuth(
parameters:
| Bidi.Network.ContinueWithAuthCredentials
| Bidi.Network.ContinueWithAuthNoCredentials
): Promise<void> {
if (parameters.action === 'provideCredentials') {
await this.#session.send('network.continueWithAuth', {
request: this.id,
action: parameters.action,
credentials: parameters.credentials,
});
} else {
await this.#session.send('network.continueWithAuth', {
request: this.id,
action: parameters.action,
});
}
}
@inertIfDisposed

@@ -206,0 +233,0 @@ private dispose(): void {

@@ -84,3 +84,2 @@ /**

// keep-sorted start
#reason: string | undefined;

@@ -92,10 +91,8 @@ readonly #disposables = new DisposableStack();

accessor connection: Connection;
// keep-sorted end
private constructor(connection: Connection, info: Bidi.Session.NewResult) {
super();
// keep-sorted start
this.#info = info;
this.connection = connection;
// keep-sorted end
}

@@ -126,3 +123,2 @@

// keep-sorted start block=yes
get capabilities(): Bidi.Session.NewResult['capabilities'] {

@@ -140,3 +136,2 @@ return this.#info.capabilities;

}
// keep-sorted end

@@ -143,0 +138,0 @@ @inertIfDisposed

@@ -55,3 +55,2 @@ /**

// keep-sorted start
#reason?: string;

@@ -63,10 +62,8 @@ // Note these are only top-level contexts.

readonly browser: Browser;
// keep-sorted end
private constructor(browser: Browser, id: string) {
super();
// keep-sorted start
this.#id = id;
this.browser = browser;
// keep-sorted end
}

@@ -115,3 +112,2 @@

// keep-sorted start block=yes
get #session() {

@@ -132,3 +128,2 @@ return this.browser.session;

}
// keep-sorted end

@@ -135,0 +130,0 @@ @inertIfDisposed

@@ -52,3 +52,2 @@ /**

// keep-sorted start
#reason?: string;

@@ -59,3 +58,2 @@ #result?: UserPromptResult;

readonly info: Bidi.BrowsingContext.UserPromptOpenedParameters;
// keep-sorted end

@@ -67,6 +65,5 @@ private constructor(

super();
// keep-sorted start
this.browsingContext = context;
this.info = info;
// keep-sorted end
}

@@ -95,3 +92,2 @@

// keep-sorted start block=yes
get #session() {

@@ -112,3 +108,2 @@ return this.browsingContext.userContext.browser.session;

}
// keep-sorted end

@@ -115,0 +110,0 @@ @inertIfDisposed

@@ -40,2 +40,3 @@ /**

import {debugError, fromEmitterEvent, timeout} from '../common/util.js';
import {isErrorLike} from '../util/ErrorLike.js';

@@ -118,3 +119,2 @@ import {BidiCdpSession} from './CDPSession.js';

request.once('success', () => {
// SAFETY: BidiHTTPRequest will create this before here.
this.page().trustedEmitter.emit(PageEvent.RequestFinished, httpRequest);

@@ -306,6 +306,14 @@ });

// Related: https://bugzilla.mozilla.org/show_bug.cgi?id=1846601
this.browsingContext.navigate(
url,
Bidi.BrowsingContext.ReadinessState.Interactive
),
this.browsingContext
.navigate(url, Bidi.BrowsingContext.ReadinessState.Interactive)
.catch(error => {
if (
isErrorLike(error) &&
error.message.includes('net::ERR_HTTP_RESPONSE_CODE_FAILURE')
) {
return;
}
throw error;
}),
]).catch(

@@ -358,7 +366,3 @@ rewriteNavigationError(

fromEmitterEvent(navigation, 'fragment'),
fromEmitterEvent(navigation, 'failed').pipe(
map(({url}) => {
throw new Error(`Navigation failed: ${url}`);
})
),
fromEmitterEvent(navigation, 'failed'),
fromEmitterEvent(navigation, 'aborted').pipe(

@@ -365,0 +369,0 @@ map(({url}) => {

@@ -75,2 +75,3 @@ /**

});
this.#request.on('authenticate', this.#handleAuthentication);

@@ -236,2 +237,25 @@ this.#frame?.page().trustedEmitter.emit(PageEvent.Request, this);

}
#authenticationHandled = false;
#handleAuthentication = async () => {
if (!this.#frame) {
return;
}
const credentials = this.#frame.page()._credentials;
if (credentials && !this.#authenticationHandled) {
this.#authenticationHandled = true;
void this.#request.continueWithAuth({
action: 'provideCredentials',
credentials: {
type: 'password',
username: credentials.username,
password: credentials.password,
},
});
} else {
void this.#request.continueWithAuth({
action: 'cancel',
});
}
};
}

@@ -238,0 +262,0 @@

@@ -16,2 +16,3 @@ /**

import type {
Credentials,
GeolocationOptions,

@@ -518,6 +519,3 @@ MediaFeature,

this.#interception = await this.#frame.browsingContext.addIntercept({
phases: [
Bidi.Network.InterceptPhase.BeforeRequestSent,
Bidi.Network.InterceptPhase.AuthRequired,
],
phases: [Bidi.Network.InterceptPhase.BeforeRequestSent],
});

@@ -532,2 +530,21 @@ } else if (!enable && this.#interception) {

/**
* @internal
*/
_credentials: Credentials | null = null;
#authInterception?: string;
override async authenticate(credentials: Credentials | null): Promise<void> {
if (credentials && !this.#authInterception) {
this.#authInterception = await this.#frame.browsingContext.addIntercept({
phases: [Bidi.Network.InterceptPhase.AuthRequired],
});
} else if (!credentials && this.#authInterception) {
await this.#frame.browsingContext.userContext.browser.removeIntercept(
this.#authInterception
);
this.#authInterception = undefined;
}
this._credentials = credentials;
}
override setDragInterception(): never {

@@ -643,6 +660,2 @@ throw new UnsupportedOperation();

override authenticate(): never {
throw new UnsupportedOperation();
}
override setExtraHTTPHeaders(): never {

@@ -649,0 +662,0 @@ throw new UnsupportedOperation();

@@ -30,3 +30,12 @@ /**

return nodes.filter((node: Protocol.Accessibility.AXNode) => {
return !node.role || !NON_ELEMENT_NODE_ROLES.has(node.role.value);
if (node.ignored) {
return false;
}
if (!node.role) {
return false;
}
if (NON_ELEMENT_NODE_ROLES.has(node.role.value)) {
return false;
}
return true;
});

@@ -33,0 +42,0 @@ };

@@ -24,2 +24,3 @@ /**

#mainFrame?: FrameType;
#isMainFrameStale = false;
#waitRequests = new Map<string, Set<Deferred<FrameType>>>();

@@ -63,4 +64,5 @@

this.#childIds.get(frame._parentId)!.add(frame._id);
} else if (!this.#mainFrame) {
} else if (!this.#mainFrame || this.#isMainFrameStale) {
this.#mainFrame = frame;
this.#isMainFrameStale = false;
}

@@ -78,3 +80,3 @@ this.#waitRequests.get(frame._id)?.forEach(request => {

} else {
this.#mainFrame = undefined;
this.#isMainFrameStale = true;
}

@@ -81,0 +83,0 @@ }

@@ -11,2 +11,3 @@ /**

import type {Frame} from '../api/Frame.js';
import type {Credentials} from '../api/Page.js';
import {EventEmitter, EventSubscription} from '../common/EventEmitter.js';

@@ -31,10 +32,2 @@ import {

*/
export interface Credentials {
username: string;
password: string;
}
/**
* @public
*/
export interface NetworkConditions {

@@ -41,0 +34,0 @@ /**

@@ -18,2 +18,3 @@ /**

import type {JSHandle} from '../api/JSHandle.js';
import type {Credentials} from '../api/Page.js';
import {

@@ -75,3 +76,3 @@ Page,

import {releaseObject} from './JSHandle.js';
import type {Credentials, NetworkConditions} from './NetworkManager.js';
import type {NetworkConditions} from './NetworkManager.js';
import type {CdpTarget} from './Target.js';

@@ -78,0 +79,0 @@ import type {TargetManager} from './TargetManager.js';

@@ -101,3 +101,3 @@ /**

* HTML template for the print footer. Has the same constraints and support
* for special classes as {@link PDFOptions | PDFOptions.headerTemplate}.
* for special classes as {@link PDFOptions.headerTemplate}.
*/

@@ -104,0 +104,0 @@ footerTemplate?: string;

/**
* @internal
*/
export const packageVersion = '22.6.3';
export const packageVersion = '22.6.4';

@@ -139,7 +139,7 @@ /**

* When using with `puppeteer-core`,
* {@link LaunchOptions | options.executablePath} or
* {@link LaunchOptions | options.channel} must be provided.
* {@link LaunchOptions.executablePath | options.executablePath} or
* {@link LaunchOptions.channel | options.channel} must be provided.
*
* @example
* You can use {@link LaunchOptions | options.ignoreDefaultArgs}
* You can use {@link LaunchOptions.ignoreDefaultArgs | options.ignoreDefaultArgs}
* to filter out `--mute-audio` from default arguments:

@@ -146,0 +146,0 @@ *

@@ -11,5 +11,5 @@ /**

export const PUPPETEER_REVISIONS = Object.freeze({
chrome: '123.0.6312.105',
'chrome-headless-shell': '123.0.6312.105',
chrome: '123.0.6312.122',
'chrome-headless-shell': '123.0.6312.122',
firefox: 'latest',
});

@@ -75,3 +75,3 @@ /**

new RegExp(`PLACEHOLDER\\(\\s*(?:'${name}'|"${name}")\\s*\\)`, 'g'),
// Wrapping this ensures tersers that accidently inline PLACEHOLDER calls
// Wrapping this ensures tersers that accidentally inline PLACEHOLDER calls
// are still valid. Without, we may get calls like ()=>{...}() which is

@@ -78,0 +78,0 @@ // not valid.

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc