Screen - puppeteerApp
屏幕类,用于获取屏幕截图、像素颜色等
Screen.requestPermission ⇒ Promise.<boolean>
请求权限 Requests permission for the application screen with an optional timeout.
Kind: static property of Screen
Returns: Promise.<boolean>
- - A promise that resolves with a boolean indicating whether the permission was granted or not.
Param | Type | Default | Description |
---|---|---|---|
options | Object | Options for the permission request. | |
[options.timeout] | number | 30000 | Timeout in milliseconds for the permission request. |
Screen.screenshot ⇒ *
获取屏幕截图 Takes a screenshot of the application screen with the given options.
Kind: static property of Screen
Returns: *
- - The result of the screenshot operation.
Param | Type | Description |
---|---|---|
options | Object | Options for the screenshot. |
Screen.isEnabled ⇒ boolean
检查是否启用,如果启用则返回 true,否则返回 false。 启用后可以访问屏幕截图、像素颜色等功能。 Checks if the application screen is enabled.
Kind: static property of Screen
Returns: 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
Param | Type | Description |
---|---|---|
width | number | The width of the screen. |
height | number | The 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 Screen
Returns: *
- - The color of the pixel at the specified coordinates.
Param | Type | Description |
---|---|---|
x | number | The x-coordinate of the pixel. |
y | number | The y-coordinate of the pixel. |
Screen.color ⇒ *
获取元素中心像素颜色,16 进制字符串,小写,如 #ffffff。
Kind: static property of Screen
Returns: *
- - The color of the pixel at the specified coordinates.
Param | Type | Description |
---|---|---|
button | * | The button object with boundsInScreen property. For example, button = await page.$('#button'); button.boundsInScreen = { left, top, right, bottom }; |