跳至主要内容
版本: 22.5.0

预定义网络条件变量

要与 Page.emulateNetworkConditions() 一起使用的网络条件列表。

签名:

PredefinedNetworkConditions: Readonly<{
'Slow 3G': NetworkConditions;
'Fast 3G': NetworkConditions;
}>;

示例

import {PredefinedNetworkConditions} from 'puppeteer';
const slow3G = PredefinedNetworkConditions['Slow 3G'];

(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.emulateNetworkConditions(slow3G);
await page.goto('https://www.google.com');
// other actions...
await browser.close();
})();