mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-15 06:48:25 +08:00
Merge pull request #28617 from ninoseki/update-puppeteer-definition
feat: update puppeteer definition
This commit is contained in:
7
types/puppeteer/index.d.ts
vendored
7
types/puppeteer/index.d.ts
vendored
@@ -585,6 +585,11 @@ export interface ScreenshotOptions {
|
||||
* @default false
|
||||
*/
|
||||
omitBackground?: boolean;
|
||||
/**
|
||||
* The encoding of the image, can be either base64 or binary. Defaults to binary
|
||||
* @default binary
|
||||
*/
|
||||
encoding?: "base64" | "binary";
|
||||
}
|
||||
|
||||
/** Options for `addStyleTag` */
|
||||
@@ -1341,7 +1346,7 @@ export interface Page extends EventEmitter, FrameBase {
|
||||
* Captures a screenshot of the page.
|
||||
* @param options The screenshot options.
|
||||
*/
|
||||
screenshot(options?: ScreenshotOptions): Promise<Buffer>;
|
||||
screenshot(options?: ScreenshotOptions): Promise<string | Buffer>;
|
||||
|
||||
/**
|
||||
* Triggers a `change` and `input` event once all the provided options have been selected.
|
||||
|
||||
@@ -397,3 +397,14 @@ puppeteer.launch().then(async browser => {
|
||||
);
|
||||
index; // $ExpectType number
|
||||
});
|
||||
|
||||
// Test screenshot with an encoding option
|
||||
(async () => {
|
||||
const browser = await puppeteer.launch();
|
||||
const page = await browser.newPage();
|
||||
await page.goto("https://example.com");
|
||||
const base64string: string = (await page.screenshot({ encoding: "base64" })) as string;
|
||||
const buffer: Buffer = (await page.screenshot({ encoding: "binary" })) as Buffer;
|
||||
|
||||
browser.close();
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user