setTimeout
设置与当前会话相关的超时时间,超时持续时间控制脚本注入、文档导航和元素检索等行为。 更多信息和示例,请参阅超时指南。
信息
不建议设置implicit
超时,因为它们会影响WebdriverIO的行为,
并可能在某些命令中导致错误,例如带有反向标志的waitForExist
。
用法
browser.setTimeout({ implicit, pageLoad, script })
参数
名称 | 类型 | 详情 |
---|---|---|
timeouts | Timeouts | 包含会话超时值的对象 |
timeouts.implicit 可选 | Number | 查找元素时重试元素定位策略的毫秒时间。 |
timeouts.pageLoad 可选 | Number | 等待文档完成加载的毫秒时间。 |
timeouts.script 可选 | Number | 通过execute 或executeAsync 注入的脚本将运行,直到达到脚本超时时间(也以毫秒为单位)。 |
示例
setTimeout.js
it('should change timeout duration for session with long code duration', async () => {
await browser.setTimeout({
'pageLoad': 10000,
'script': 60000
});
// Execute code which takes a long time
await browser.executeAsync((done) => {
console.log('Wake me up before you go!');
setTimeout(done, 59000);
});
});