Skip to content

Screen - puppeteerApp

屏幕类,用于获取屏幕截图、像素颜色等

Screen.requestPermission ⇒ Promise.<boolean>

请求权限 Requests permission for the application screen with an optional timeout.

Kind: static property of ScreenReturns: Promise.<boolean> - - A promise that resolves with a boolean indicating whether the permission was granted or not.

ParamTypeDefaultDescription
optionsObjectOptions for the permission request.
[options.timeout]number30000Timeout in milliseconds for the permission request.

Screen.screenshot ⇒ *

获取屏幕截图 Takes a screenshot of the application screen with the given options.

Kind: static property of ScreenReturns: * - - The result of the screenshot operation.

ParamTypeDescription
optionsObjectOptions for the screenshot.

Screen.isEnabled ⇒ boolean

检查是否启用,如果启用则返回 true,否则返回 false。 启用后可以访问屏幕截图、像素颜色等功能。 Checks if the application screen is enabled.

Kind: static property of ScreenReturns: boolean - - A boolean indicating whether the screen is enabled or not.

Screen.setMetrics

设置屏幕尺寸,用于统一不同设备屏幕尺寸下执行脚本的坐标,确保代码运行效果。不同屏幕尺寸下,坐标值会自动缩放; Sets the metrics (width and height) of the application screen.

Kind: static property of Screen

ParamTypeDescription
widthnumberThe width of the screen.
heightnumberThe height of the screen.

Screen.pixel ⇒ *

获取像素颜色,16 进制字符串,小写,如 #ffffff。 Retrieves the color of a pixel at the specified coordinates on the application screen.

Kind: static property of ScreenReturns: * - - The color of the pixel at the specified coordinates.

ParamTypeDescription
xnumberThe x-coordinate of the pixel.
ynumberThe y-coordinate of the pixel.

Screen.color ⇒ *

获取元素中心像素颜色,16 进制字符串,小写,如 #ffffff。

Kind: static property of ScreenReturns: * - - The color of the pixel at the specified coordinates.

ParamTypeDescription
button*The button object with boundsInScreen property. For example, button = await page.$('#button'); button.boundsInScreen = { left, top, right, bottom };