@crawlee/playwright 4.0.0-beta.15 → 4.0.0-beta.151
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -14
- package/index.d.ts +2 -2
- package/index.js +1 -1
- package/internals/adaptive-playwright-crawler.d.ts +116 -63
- package/internals/adaptive-playwright-crawler.js +320 -266
- package/internals/enqueue-links/click-elements.d.ts +36 -64
- package/internals/enqueue-links/click-elements.js +65 -67
- package/internals/playwright-browser-pool.d.ts +71 -0
- package/internals/playwright-browser-pool.js +61 -0
- package/internals/playwright-crawler.d.ts +180 -125
- package/internals/playwright-crawler.js +68 -63
- package/internals/playwright-launcher.d.ts +32 -18
- package/internals/playwright-launcher.js +23 -17
- package/internals/utils/playwright-utils.d.ts +54 -41
- package/internals/utils/playwright-utils.js +110 -121
- package/internals/utils/rendering-type-prediction.d.ts +25 -11
- package/internals/utils/rendering-type-prediction.js +81 -27
- package/package.json +14 -18
- package/index.d.ts.map +0 -1
- package/index.js.map +0 -1
- package/internals/adaptive-playwright-crawler.d.ts.map +0 -1
- package/internals/adaptive-playwright-crawler.js.map +0 -1
- package/internals/enqueue-links/click-elements.d.ts.map +0 -1
- package/internals/enqueue-links/click-elements.js.map +0 -1
- package/internals/playwright-crawler.d.ts.map +0 -1
- package/internals/playwright-crawler.js.map +0 -1
- package/internals/playwright-launcher.d.ts.map +0 -1
- package/internals/playwright-launcher.js.map +0 -1
- package/internals/utils/playwright-utils.d.ts.map +0 -1
- package/internals/utils/playwright-utils.js.map +0 -1
- package/internals/utils/rendering-type-prediction.d.ts.map +0 -1
- package/internals/utils/rendering-type-prediction.js.map +0 -1
|
@@ -3,6 +3,7 @@ import { BrowserLauncher, Configuration } from '@crawlee/browser';
|
|
|
3
3
|
import { PlaywrightPlugin } from '@crawlee/browser-pool';
|
|
4
4
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
5
5
|
import type { Browser, BrowserType, LaunchOptions } from 'playwright';
|
|
6
|
+
import { z } from 'zod';
|
|
6
7
|
/**
|
|
7
8
|
* Apify extends the launch options of Playwright.
|
|
8
9
|
* You can use any of the Playwright compatible
|
|
@@ -70,31 +71,45 @@ export interface PlaywrightLaunchContext extends BrowserLaunchContext<LaunchOpti
|
|
|
70
71
|
* @ignore
|
|
71
72
|
*/
|
|
72
73
|
export declare class PlaywrightLauncher extends BrowserLauncher<PlaywrightPlugin> {
|
|
73
|
-
readonly
|
|
74
|
+
readonly configuration: Configuration;
|
|
75
|
+
/**
|
|
76
|
+
* @internal
|
|
77
|
+
*/
|
|
74
78
|
protected static optionsShape: {
|
|
79
|
+
proxyUrl: z.ZodOptional<z.ZodURL>;
|
|
80
|
+
useChrome: z.ZodOptional<z.ZodBoolean>;
|
|
81
|
+
useIncognitoPages: z.ZodOptional<z.ZodBoolean>;
|
|
82
|
+
browserPerProxy: z.ZodOptional<z.ZodBoolean>;
|
|
83
|
+
ignoreProxyCertificate: z.ZodOptional<z.ZodBoolean>;
|
|
84
|
+
userDataDir: z.ZodOptional<z.ZodString>;
|
|
75
85
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
launchContextOptions: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
|
|
79
|
-
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
80
|
-
proxyUrl: import("ow").StringPredicate & import("ow").BasePredicate<string | undefined>;
|
|
86
|
+
launchOptions: z.ZodOptional<z.ZodCustom<import("@crawlee/types").Dictionary, import("@crawlee/types").Dictionary>>;
|
|
87
|
+
userAgent: z.ZodOptional<z.ZodString>;
|
|
81
88
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
82
|
-
|
|
89
|
+
launcher: z.ZodOptional<z.ZodCustom<import("@crawlee/types").Dictionary, import("@crawlee/types").Dictionary>>;
|
|
83
90
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
91
|
+
launchContextOptions: z.ZodOptional<z.ZodCustom<import("@crawlee/types").Dictionary, import("@crawlee/types").Dictionary>>;
|
|
92
|
+
};
|
|
93
|
+
/** @internal */
|
|
94
|
+
protected static optionsSchema: z.ZodObject<{
|
|
95
|
+
proxyUrl: z.ZodOptional<z.ZodURL>;
|
|
96
|
+
useChrome: z.ZodOptional<z.ZodBoolean>;
|
|
97
|
+
useIncognitoPages: z.ZodOptional<z.ZodBoolean>;
|
|
98
|
+
browserPerProxy: z.ZodOptional<z.ZodBoolean>;
|
|
99
|
+
ignoreProxyCertificate: z.ZodOptional<z.ZodBoolean>;
|
|
100
|
+
userDataDir: z.ZodOptional<z.ZodString>;
|
|
87
101
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
88
|
-
|
|
102
|
+
launchOptions: z.ZodOptional<z.ZodCustom<import("@crawlee/types").Dictionary, import("@crawlee/types").Dictionary>>;
|
|
103
|
+
userAgent: z.ZodOptional<z.ZodString>;
|
|
89
104
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
90
|
-
|
|
105
|
+
launcher: z.ZodOptional<z.ZodCustom<import("@crawlee/types").Dictionary, import("@crawlee/types").Dictionary>>;
|
|
91
106
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
92
|
-
|
|
93
|
-
}
|
|
107
|
+
launchContextOptions: z.ZodOptional<z.ZodCustom<import("@crawlee/types").Dictionary, import("@crawlee/types").Dictionary>>;
|
|
108
|
+
}, z.core.$strict>;
|
|
94
109
|
/**
|
|
95
110
|
* All `PlaywrightLauncher` parameters are passed via this launchContext object.
|
|
96
111
|
*/
|
|
97
|
-
constructor(launchContext?: PlaywrightLaunchContext,
|
|
112
|
+
constructor(launchContext?: PlaywrightLaunchContext, configuration?: Configuration);
|
|
98
113
|
}
|
|
99
114
|
/**
|
|
100
115
|
* Launches headless browsers using Playwright pre-configured to work within the Apify platform.
|
|
@@ -125,9 +140,8 @@ export declare class PlaywrightLauncher extends BrowserLauncher<PlaywrightPlugin
|
|
|
125
140
|
* Optional settings passed to `browserType.launch()`. In addition to
|
|
126
141
|
* [Playwright's options](https://playwright.dev/docs/api/class-browsertype?_highlight=launch#browsertypelaunchoptions)
|
|
127
142
|
* the object may contain our own {@link PlaywrightLaunchContext} that enable additional features.
|
|
128
|
-
* @param [
|
|
143
|
+
* @param [configuration]
|
|
129
144
|
* @returns
|
|
130
145
|
* Promise that resolves to Playwright's `Browser` instance.
|
|
131
146
|
*/
|
|
132
|
-
export declare function launchPlaywright(launchContext?: PlaywrightLaunchContext,
|
|
133
|
-
//# sourceMappingURL=playwright-launcher.d.ts.map
|
|
147
|
+
export declare function launchPlaywright(launchContext?: PlaywrightLaunchContext, configuration?: Configuration): Promise<Browser>;
|
|
@@ -1,33 +1,40 @@
|
|
|
1
1
|
import { BrowserLauncher, Configuration } from '@crawlee/browser';
|
|
2
2
|
import { PlaywrightPlugin } from '@crawlee/browser-pool';
|
|
3
|
-
import
|
|
3
|
+
import { parseArgument, schemas } from '@crawlee/utils/internal';
|
|
4
|
+
import { z } from 'zod';
|
|
4
5
|
/**
|
|
5
6
|
* `PlaywrightLauncher` is based on the `BrowserLauncher`. It launches `playwright` browser instance.
|
|
6
7
|
* @ignore
|
|
7
8
|
*/
|
|
8
9
|
export class PlaywrightLauncher extends BrowserLauncher {
|
|
9
|
-
|
|
10
|
+
configuration;
|
|
11
|
+
/**
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
10
14
|
static optionsShape = {
|
|
11
15
|
...BrowserLauncher.optionsShape,
|
|
12
|
-
launcher
|
|
13
|
-
|
|
16
|
+
// Passthrough schemas — the launcher module object must keep its prototype through parsing.
|
|
17
|
+
launcher: schemas.anyObject.optional(),
|
|
18
|
+
launchContextOptions: schemas.anyObject.optional(),
|
|
14
19
|
};
|
|
20
|
+
/** @internal */
|
|
21
|
+
static optionsSchema = z.strictObject(PlaywrightLauncher.optionsShape);
|
|
15
22
|
/**
|
|
16
23
|
* All `PlaywrightLauncher` parameters are passed via this launchContext object.
|
|
17
24
|
*/
|
|
18
|
-
constructor(launchContext = {},
|
|
19
|
-
|
|
20
|
-
const { launcher = BrowserLauncher.requireLauncherOrThrow('playwright', 'apify/actor-node-playwright-*').chromium, } =
|
|
21
|
-
const { launchOptions = {}, ...rest } =
|
|
25
|
+
constructor(launchContext = {}, configuration = Configuration.getGlobalConfiguration()) {
|
|
26
|
+
const parsedContext = parseArgument(launchContext, PlaywrightLauncher.optionsSchema, 'PlaywrightLaunchContext');
|
|
27
|
+
const { launcher = BrowserLauncher.requireLauncherOrThrow('playwright', 'apify/actor-node-playwright-*').chromium, } = parsedContext;
|
|
28
|
+
const { launchOptions = {}, ...rest } = parsedContext;
|
|
22
29
|
super({
|
|
23
30
|
...rest,
|
|
24
31
|
launchOptions: {
|
|
25
32
|
...launchOptions,
|
|
26
|
-
executablePath: getDefaultExecutablePath(
|
|
33
|
+
executablePath: getDefaultExecutablePath(parsedContext, configuration),
|
|
27
34
|
},
|
|
28
35
|
launcher,
|
|
29
|
-
},
|
|
30
|
-
this.
|
|
36
|
+
}, configuration);
|
|
37
|
+
this.configuration = configuration;
|
|
31
38
|
this.Plugin = PlaywrightPlugin;
|
|
32
39
|
}
|
|
33
40
|
}
|
|
@@ -36,8 +43,8 @@ export class PlaywrightLauncher extends BrowserLauncher {
|
|
|
36
43
|
* @returns default path to browser.
|
|
37
44
|
* @ignore
|
|
38
45
|
*/
|
|
39
|
-
function getDefaultExecutablePath(launchContext,
|
|
40
|
-
const pathFromPlaywrightImage =
|
|
46
|
+
function getDefaultExecutablePath(launchContext, configuration) {
|
|
47
|
+
const pathFromPlaywrightImage = configuration.defaultBrowserPath;
|
|
41
48
|
const { launchOptions = {} } = launchContext;
|
|
42
49
|
if (launchOptions.executablePath) {
|
|
43
50
|
return launchOptions.executablePath;
|
|
@@ -79,12 +86,11 @@ function getDefaultExecutablePath(launchContext, config) {
|
|
|
79
86
|
* Optional settings passed to `browserType.launch()`. In addition to
|
|
80
87
|
* [Playwright's options](https://playwright.dev/docs/api/class-browsertype?_highlight=launch#browsertypelaunchoptions)
|
|
81
88
|
* the object may contain our own {@link PlaywrightLaunchContext} that enable additional features.
|
|
82
|
-
* @param [
|
|
89
|
+
* @param [configuration]
|
|
83
90
|
* @returns
|
|
84
91
|
* Promise that resolves to Playwright's `Browser` instance.
|
|
85
92
|
*/
|
|
86
|
-
export async function launchPlaywright(launchContext,
|
|
87
|
-
const playwrightLauncher = new PlaywrightLauncher(launchContext,
|
|
93
|
+
export async function launchPlaywright(launchContext, configuration = Configuration.getGlobalConfiguration()) {
|
|
94
|
+
const playwrightLauncher = new PlaywrightLauncher(launchContext, configuration);
|
|
88
95
|
return playwrightLauncher.launch();
|
|
89
96
|
}
|
|
90
|
-
//# sourceMappingURL=playwright-launcher.js.map
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
* ```
|
|
18
18
|
* @module playwrightUtils
|
|
19
19
|
*/
|
|
20
|
-
import { Configuration, type Request
|
|
21
|
-
import type { BatchAddRequestsResult } from '@crawlee/types';
|
|
22
|
-
import
|
|
20
|
+
import { Configuration, type Request } from '@crawlee/browser';
|
|
21
|
+
import type { BatchAddRequestsResult, Dictionary } from '@crawlee/types';
|
|
22
|
+
import type { CheerioAPI } from 'cheerio';
|
|
23
23
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
24
|
-
import type { Page, Response } from 'playwright';
|
|
24
|
+
import type { Download, Page, Response } from 'playwright';
|
|
25
25
|
import type { EnqueueLinksByClickingElementsOptions } from '../enqueue-links/click-elements.js';
|
|
26
26
|
import { enqueueLinksByClickingElements } from '../enqueue-links/click-elements.js';
|
|
27
27
|
import { RenderingTypePredictor } from './rendering-type-prediction.js';
|
|
@@ -265,9 +265,9 @@ export interface SaveSnapshotOptions {
|
|
|
265
265
|
keyValueStoreName?: string | null;
|
|
266
266
|
/**
|
|
267
267
|
* Configuration of the crawler that will be used to save the snapshot.
|
|
268
|
-
* @default Configuration.
|
|
268
|
+
* @default Configuration.getGlobalConfiguration()
|
|
269
269
|
*/
|
|
270
|
-
|
|
270
|
+
configuration?: Configuration;
|
|
271
271
|
}
|
|
272
272
|
/**
|
|
273
273
|
* Saves a full screenshot and HTML of the current page into a Key-Value store.
|
|
@@ -287,8 +287,7 @@ export declare function saveSnapshot(page: Page, options?: SaveSnapshotOptions):
|
|
|
287
287
|
* @param page Playwright [`Page`](https://playwright.dev/docs/api/class-page) object.
|
|
288
288
|
* @param ignoreShadowRoots
|
|
289
289
|
*/
|
|
290
|
-
export declare function parseWithCheerio(page: Page, ignoreShadowRoots?: boolean, ignoreIframes?: boolean): Promise<
|
|
291
|
-
export declare function closeCookieModals(page: Page): Promise<void>;
|
|
290
|
+
export declare function parseWithCheerio(page: Page, ignoreShadowRoots?: boolean, ignoreIframes?: boolean): Promise<CheerioAPI>;
|
|
292
291
|
export interface HandleCloudflareChallengeOptions {
|
|
293
292
|
/** Logging defaults to the `debug` level, use this flag to log to `info` level instead. */
|
|
294
293
|
verbose?: boolean;
|
|
@@ -303,6 +302,13 @@ export interface HandleCloudflareChallengeOptions {
|
|
|
303
302
|
isChallengeCallback?: (page: Page) => Promise<boolean>;
|
|
304
303
|
/** Allows overriding the detection of Cloudflare "blocked page". */
|
|
305
304
|
isBlockedCallback?: (page: Page) => Promise<boolean>;
|
|
305
|
+
/** Allows overriding how the checkbox click position is calculated. */
|
|
306
|
+
clickPositionCallback?: (page: Page) => Promise<{
|
|
307
|
+
x: number;
|
|
308
|
+
y: number;
|
|
309
|
+
} | null>;
|
|
310
|
+
/** Optional delay (in seconds) before the first click attempt on the challenge checkbox. Defaults to 1s. */
|
|
311
|
+
preChallengeSleepSecs?: number;
|
|
306
312
|
}
|
|
307
313
|
/**
|
|
308
314
|
* This helper tries to solve the Cloudflare challenge automatically by clicking on the checkbox.
|
|
@@ -311,24 +317,24 @@ export interface HandleCloudflareChallengeOptions {
|
|
|
311
317
|
* result in a SessionError which will be automatically retried, so only successful requests will get
|
|
312
318
|
* into the `requestHandler`.
|
|
313
319
|
*
|
|
320
|
+
* On a successfully solved challenge the page is reloaded and the new {@link Response} is returned, so
|
|
321
|
+
* it can be propagated back to the crawling context via a hook return value (see
|
|
322
|
+
* {@link handleCloudflareChallengeHook}).
|
|
323
|
+
*
|
|
314
324
|
* Works best with camoufox.
|
|
315
325
|
*
|
|
316
326
|
* **Example usage**
|
|
317
327
|
* ```ts
|
|
318
328
|
* postNavigationHooks: [
|
|
319
|
-
* async ({ handleCloudflareChallenge })
|
|
320
|
-
* await handleCloudflareChallenge();
|
|
321
|
-
* },
|
|
329
|
+
* async (context) => ({ response: await context.handleCloudflareChallenge() }),
|
|
322
330
|
* ],
|
|
323
331
|
* ```
|
|
324
332
|
*
|
|
325
333
|
* @param page Playwright [`Page`](https://playwright.dev/docs/api/class-page) object
|
|
326
334
|
* @param url current URL for request identification, only used for logging
|
|
327
|
-
* @param [session] current session object
|
|
328
335
|
* @param [options]
|
|
329
336
|
*/
|
|
330
|
-
declare function handleCloudflareChallenge(page: Page, url: string,
|
|
331
|
-
/** @internal */
|
|
337
|
+
declare function handleCloudflareChallenge(page: Page, url: string, options?: HandleCloudflareChallengeOptions): Promise<Response | undefined>;
|
|
332
338
|
export interface PlaywrightContextUtils {
|
|
333
339
|
/**
|
|
334
340
|
* Injects a JavaScript file into current `page`.
|
|
@@ -427,7 +433,7 @@ export interface PlaywrightContextUtils {
|
|
|
427
433
|
* });
|
|
428
434
|
* ```
|
|
429
435
|
*/
|
|
430
|
-
parseWithCheerio(selector?: string, timeoutMs?: number): Promise<
|
|
436
|
+
parseWithCheerio(selector?: string, timeoutMs?: number): Promise<CheerioAPI>;
|
|
431
437
|
/**
|
|
432
438
|
* Scrolls to the bottom of a page, or until it times out.
|
|
433
439
|
* Loads dynamic content when it hits the bottom of a page, and then continues scrolling.
|
|
@@ -447,8 +453,7 @@ export interface PlaywrightContextUtils {
|
|
|
447
453
|
* in `href` elements, but rather navigations are triggered in click handlers.
|
|
448
454
|
* If you're looking to find URLs in `href` attributes of the page, see {@link enqueueLinks}.
|
|
449
455
|
*
|
|
450
|
-
* Optionally, the function allows you to filter the target links' URLs using an array of
|
|
451
|
-
* and override settings of the enqueued {@link Request} objects.
|
|
456
|
+
* Optionally, the function allows you to filter the target links' URLs using an array of glob or regexp patterns.
|
|
452
457
|
*
|
|
453
458
|
* **IMPORTANT**: To be able to do this, this function uses various mutations on the page,
|
|
454
459
|
* such as changing the Z-index of elements being clicked and their visibility. Therefore,
|
|
@@ -469,9 +474,9 @@ export interface PlaywrightContextUtils {
|
|
|
469
474
|
* async requestHandler({ enqueueLinksByClickingElements }) {
|
|
470
475
|
* await enqueueLinksByClickingElements({
|
|
471
476
|
* selector: 'a.product-detail',
|
|
472
|
-
*
|
|
473
|
-
* 'https://www.example.com/handbags/**'
|
|
474
|
-
* 'https://www.example.com/purses/**'
|
|
477
|
+
* include: [
|
|
478
|
+
* 'https://www.example.com/handbags/**',
|
|
479
|
+
* 'https://www.example.com/purses/**',
|
|
475
480
|
* ],
|
|
476
481
|
* });
|
|
477
482
|
* });
|
|
@@ -479,7 +484,7 @@ export interface PlaywrightContextUtils {
|
|
|
479
484
|
*
|
|
480
485
|
* @returns Promise that resolves to {@link BatchAddRequestsResult} object.
|
|
481
486
|
*/
|
|
482
|
-
enqueueLinksByClickingElements(options: Omit<EnqueueLinksByClickingElementsOptions, 'page' | '
|
|
487
|
+
enqueueLinksByClickingElements(options: Omit<EnqueueLinksByClickingElementsOptions, 'page' | 'requestManager'>): Promise<BatchAddRequestsResult>;
|
|
483
488
|
/**
|
|
484
489
|
* Compiles a Playwright script into an async function that may be executed at any time
|
|
485
490
|
* by providing it with the following object:
|
|
@@ -507,19 +512,6 @@ export interface PlaywrightContextUtils {
|
|
|
507
512
|
* secured copies beforehand.
|
|
508
513
|
*/
|
|
509
514
|
compileScript(scriptString: string, ctx?: Dictionary): CompiledScriptFunction;
|
|
510
|
-
/**
|
|
511
|
-
* Tries to close cookie consent modals on the page. Based on the I Don't Care About Cookies browser extension.
|
|
512
|
-
*
|
|
513
|
-
* Note that this method requires the idcac-playwright package to be installed.
|
|
514
|
-
* Crawlee does not include it by default due to licensing issues.
|
|
515
|
-
*
|
|
516
|
-
* To use this method, please install the package manually by running:
|
|
517
|
-
*
|
|
518
|
-
* ```bash
|
|
519
|
-
* npm install idcac-playwright
|
|
520
|
-
* ```
|
|
521
|
-
*/
|
|
522
|
-
closeCookieModals(): Promise<void>;
|
|
523
515
|
/**
|
|
524
516
|
* This helper tries to solve the Cloudflare challenge automatically by clicking on the checkbox.
|
|
525
517
|
* It will try to detect the Cloudflare page, click on the checkbox, and wait for 10 seconds (configurable
|
|
@@ -527,20 +519,43 @@ export interface PlaywrightContextUtils {
|
|
|
527
519
|
* result in a SessionError which will be automatically retried, so only successful requests will get
|
|
528
520
|
* into the `requestHandler`.
|
|
529
521
|
*
|
|
530
|
-
*
|
|
522
|
+
* On a successfully solved challenge the page is reloaded and the new {@link Response} is returned,
|
|
523
|
+
* which can be returned from the hook to update the crawling context's `response`. For the common case,
|
|
524
|
+
* prefer the pre-wrapped {@link handleCloudflareChallengeHook} hook.
|
|
531
525
|
*
|
|
532
526
|
* **Example usage**
|
|
533
527
|
* ```ts
|
|
534
528
|
* postNavigationHooks: [
|
|
535
|
-
* async ({ handleCloudflareChallenge })
|
|
536
|
-
* await handleCloudflareChallenge();
|
|
537
|
-
* },
|
|
529
|
+
* async (context) => ({ response: await context.handleCloudflareChallenge() }),
|
|
538
530
|
* ],
|
|
539
531
|
* ```
|
|
540
532
|
*
|
|
541
533
|
* @param [options]
|
|
542
534
|
*/
|
|
543
|
-
handleCloudflareChallenge(options?: HandleCloudflareChallengeOptions): Promise<
|
|
535
|
+
handleCloudflareChallenge(options?: HandleCloudflareChallengeOptions): Promise<Response | undefined>;
|
|
536
|
+
/**
|
|
537
|
+
* Returns the list of {@link https://playwright.dev/docs/api/class-download | Download} objects
|
|
538
|
+
* collected during the current page navigation and request handler.
|
|
539
|
+
*
|
|
540
|
+
* Useful for accessing files that the page downloads automatically.
|
|
541
|
+
* For most use cases, prefer re-enqueueing the URL to {@link FileDownload}.
|
|
542
|
+
* Use this only when direct access to the Playwright `Download` object is required.
|
|
543
|
+
*
|
|
544
|
+
* **Example usage**
|
|
545
|
+
* ```ts
|
|
546
|
+
* requestHandler: async ({ listDownloads }) => {
|
|
547
|
+
* for (const download of await listDownloads()) {
|
|
548
|
+
* try {
|
|
549
|
+
* const stream = await download.createReadStream();
|
|
550
|
+
* // stream to storage...
|
|
551
|
+
* } catch {
|
|
552
|
+
* // download failed or was cancelled
|
|
553
|
+
* }
|
|
554
|
+
* }
|
|
555
|
+
* },
|
|
556
|
+
* ```
|
|
557
|
+
*/
|
|
558
|
+
listDownloads(): Promise<Download[]>;
|
|
544
559
|
}
|
|
545
560
|
export { enqueueLinksByClickingElements };
|
|
546
561
|
/** @internal */
|
|
@@ -554,8 +569,6 @@ export declare const playwrightUtils: {
|
|
|
554
569
|
infiniteScroll: typeof infiniteScroll;
|
|
555
570
|
saveSnapshot: typeof saveSnapshot;
|
|
556
571
|
compileScript: typeof compileScript;
|
|
557
|
-
closeCookieModals: typeof closeCookieModals;
|
|
558
572
|
RenderingTypePredictor: typeof RenderingTypePredictor;
|
|
559
573
|
handleCloudflareChallenge: typeof handleCloudflareChallenge;
|
|
560
574
|
};
|
|
561
|
-
//# sourceMappingURL=playwright-utils.d.ts.map
|