Skip to main content
Version: 23.8.0

Page.emulateVisionDeficiency() 方法

¥Page.emulateVisionDeficiency() method

模拟页面上给定的视力缺陷。

¥Simulates the given vision deficiency on the page.

签名

¥Signature

class Page {
abstract emulateVisionDeficiency(
type?: Protocol.Emulation.SetEmulatedVisionDeficiencyRequest['type'],
): Promise<void>;
}

参数

¥Parameters

范围

类型

描述

type

Protocol.Emulation.SetEmulatedVisionDeficiencyRequest['type']

(可选)要模拟的缺陷类型,或要重置的 'none'

Returns:

Promise<void>

示例

¥Example

import puppeteer from 'puppeteer';

(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://v8.dev/blog/10-years');

await page.emulateVisionDeficiency('achromatopsia');
await page.screenshot({path: 'achromatopsia.png'});

await page.emulateVisionDeficiency('deuteranopia');
await page.screenshot({path: 'deuteranopia.png'});

await page.emulateVisionDeficiency('blurredVision');
await page.screenshot({path: 'blurred-vision.png'});

await browser.close();
})();