setDefaultTimeout(timeout)
设置所有接受 timeout
选项的方法的默认最大超时时间,单位为毫秒。
参数 | 类型 | 默认值 | 描述 |
---|---|---|---|
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();
context.setDefaultTimeout(1000); // 1s
const page = await context.newPage();
await page.click('h2'); // times out
}