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 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 ⇒ *
get screenshots 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。 启用后可以访问屏幕截图、像素颜色等功能。 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 Screen
Returns: 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
Param | Type | Description |
---|---|---|
width | number | The width of the screen. |
height | number | The 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 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 ⇒ *
Gets the color of the pixel at the center of the element, in hexadecimal string format, lowercase, like #ffffff.
Kind: static property of Screen
Returns: *
- The color of the pixel at the specified coordinates.
Param | Type | Description |
---|---|---|
button | * | The button object with a boundsInScreen property. For instance, button = await page.$('#button'); button.boundsInScreen = { left, top, right, bottom }; |