feat(types): export ScreenshotOptions (#6419)

This commit is contained in:
Joel Einbinder 2021-05-20 09:22:01 -07:00 committed by GitHub
parent 8490eb3c89
commit 447a0c4bb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 67 additions and 64 deletions

128
types/types.d.ts vendored
View File

@ -2418,69 +2418,7 @@ export interface Page {
* Returns the buffer with the captured screenshot.
* @param options
*/
screenshot(options?: {
/**
* An object which specifies clipping of the resulting image. Should have the following fields:
*/
clip?: {
/**
* x-coordinate of top-left corner of clip area
*/
x: number;
/**
* y-coordinate of top-left corner of clip area
*/
y: number;
/**
* width of clipping area
*/
width: number;
/**
* height of clipping area
*/
height: number;
};
/**
* When true, takes a screenshot of the full scrollable page, instead of the currently visible viewport. Defaults to
* `false`.
*/
fullPage?: boolean;
/**
* Hides default white background and allows capturing screenshots with transparency. Not applicable to `jpeg` images.
* Defaults to `false`.
*/
omitBackground?: boolean;
/**
* The file path to save the image to. The screenshot type will be inferred from file extension. If `path` is a relative
* path, then it is resolved relative to the current working directory. If no path is provided, the image won't be saved to
* the disk.
*/
path?: string;
/**
* The quality of the image, between 0-100. Not applicable to `png` images.
*/
quality?: number;
/**
* Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by
* using the
* [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browsercontextsetdefaulttimeouttimeout)
* or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#pagesetdefaulttimeouttimeout) methods.
*/
timeout?: number;
/**
* Specify screenshot type, defaults to `png`.
*/
type?: "png"|"jpeg";
}): Promise<Buffer>;
screenshot(options?: PageScreenshotOptions): Promise<Buffer>;
/**
* This method waits for an element matching `selector`, waits for [actionability](https://playwright.dev/docs/actionability) checks, waits until
@ -11499,6 +11437,70 @@ interface PageWaitForFunctionOptions {
timeout?: number;
}
export interface PageScreenshotOptions {
/**
* An object which specifies clipping of the resulting image. Should have the following fields:
*/
clip?: {
/**
* x-coordinate of top-left corner of clip area
*/
x: number;
/**
* y-coordinate of top-left corner of clip area
*/
y: number;
/**
* width of clipping area
*/
width: number;
/**
* height of clipping area
*/
height: number;
};
/**
* When true, takes a screenshot of the full scrollable page, instead of the currently visible viewport. Defaults to
* `false`.
*/
fullPage?: boolean;
/**
* Hides default white background and allows capturing screenshots with transparency. Not applicable to `jpeg` images.
* Defaults to `false`.
*/
omitBackground?: boolean;
/**
* The file path to save the image to. The screenshot type will be inferred from file extension. If `path` is a relative
* path, then it is resolved relative to the current working directory. If no path is provided, the image won't be saved to
* the disk.
*/
path?: string;
/**
* The quality of the image, between 0-100. Not applicable to `png` images.
*/
quality?: number;
/**
* Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by
* using the
* [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browsercontextsetdefaulttimeouttimeout)
* or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#pagesetdefaulttimeouttimeout) methods.
*/
timeout?: number;
/**
* Specify screenshot type, defaults to `png`.
*/
type?: "png"|"jpeg";
}
type Devices = {
"Blackberry PlayBook": DeviceDescriptor;
"Blackberry PlayBook landscape": DeviceDescriptor;

View File

@ -6,5 +6,6 @@
"BrowserNewContextOptions": "BrowserContextOptions",
"BrowserNewContextOptionsViewport": "ViewportSize",
"BrowserNewContextOptionsGeolocation": "Geolocation",
"BrowserNewContextOptionsHttpCredentials": "HTTPCredentials"
"BrowserNewContextOptionsHttpCredentials": "HTTPCredentials",
"PageScreenshotOptions": "PageScreenshotOptions"
}