ElementHandle.screenshot() 方法
screenshot(): Promise<string>
此方法在需要时会将元素滚动到视图中,然后使用 Page.screenshot() 对该元素进行截图。如果元素已从 DOM 中分离,该方法将抛出错误。
签名
class ElementHandle {
screenshot(
options: Readonly<ScreenshotOptions> & {
encoding: 'base64';
},
): Promise<string>;
}
参数
|
参数 |
类型 |
说明 |
|---|---|---|
|
options |
Readonly<ScreenshotOptions> & { encoding: 'base64'; } |
返回值:
Promise<string>
screenshot(): Promise<Uint8Array>
签名
class ElementHandle {
screenshot(options?: Readonly<ScreenshotOptions>): Promise<Uint8Array>;
}
参数
|
参数 |
类型 |
说明 |
|---|---|---|
|
options |
Readonly<ScreenshotOptions> |
(可选) |
返回值:
Promise<Uint8Array>