setDefaultNavigationTimeout(timeout)
设置 Page.goto() 的默认最大导航超时时间。
参数 | 类型 | 默认值 | 描述 |
---|---|---|---|
timeout | number | 取决于具体操作。 | 超时时间(毫秒)。 |
示例
import { browser } from 'k6/browser';
export const options = {
scenarios: {
browser: {
executor: 'shared-iterations',
options: {
browser: {
type: 'chromium',
},
},
},
},
};
export default async function () {
const context = await browser.newContext();
const page = await context.newPage();
context.setDefaultNavigationTimeout(1000); // 1s
try {
await page.goto('https://quickpizza.grafana.com/api/delay/5');
} finally {
await page.close();
}
}