Page.emulateVisionDeficiency() 方法
模拟页面上给定的视觉缺陷。
签名
class Page {
abstract emulateVisionDeficiency(
type?: Protocol.Emulation.SetEmulatedVisionDeficiencyRequest['type'],
): Promise<void>;
}
参数
参数 | 类型 | 描述 |
---|---|---|
type | Protocol.Emulation.SetEmulatedVisionDeficiencyRequest['type'] | (可选) 要模拟的缺陷类型,或 |
返回
Promise<void>
示例
import puppeteer from 'puppeteer';
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://v8.node.org.cn/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 page.emulateVisionDeficiency('reducedContrast');
await page.screenshot({path: 'reduced-contrast.png'});
await browser.close();
})();