Skip to content

Screen - puppeteerApp

Screen class, used to capture screenshots, pixel colors, etc.

Screen.requestPermission ⇒ Promise.<boolean>

Request permission 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 ⇒ *

get screenshots 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。 启用后可以访问屏幕截图、像素颜色等功能。 Check if it is enabled. If enabled, return true, otherwise return false. After enabling, you can access functions like screen capture, pixel color, etc. 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

Set the screen size to unify the coordinates of scripts executed on different device screens, ensuring the effect of code execution. Under different screen sizes, the coordinate values will be automatically scaled. 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 ⇒ *

Get pixel color, lowercase hexadecimal string, for example #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 ⇒ *

Gets the color of the pixel at the center of the element, in hexadecimal string format, lowercase, like #ffffff.

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

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