设置超时
动词:setTimeout
可从以下位置获取: <Standard>
为脚本中具有超时参数的所有命令设置缺省超时。
语法
setTimeout --timeout(TimeSpan)
输入
| 脚本 | 设计器 | 必需的 | AcceptedTypes | 描述 |
|---|---|---|---|---|
| --timeout | Timeout | 必需的 | 时间范围 | 要在脚本中使用的缺省超时。 |
示例
启动浏览器 命令将启动浏览器, 浏览 命令将访问 Web 站点 "https://www.ibm.com" , 在 Web 页面中等待元素 命令将等待具有缺省时间 (00:00:05) 的徽标元素 (如果找不到该元素) , 设置超时 命令将用于将缺省超时更改为 30 秒。
defVar --name IBMLogo --type Boolean
defVar --name IBMLogoUpdatedTimeout --type Boolean
webStart --name browser --type "Chrome"
webNavigate --url "https://www.ibm.com"
webWaitElement --selector "Id" --id logo IBMLogo=value
if --left "${IBMLogo}" --operator "Is_True" --negate
setTimeout --timeout 00:00:30
webWaitElement --selector "Id" --id logo IBMLogoUpdatedTimeout=value
assert --message "Could not load page" --left "${IBMLogoUpdatedTimeout}" --operator "Is_True"
endIf
logMessage --message "Found on first timeout: ${IBMLogo}\r\nFound on updated timeout: ${IBMLogoUpdatedTimeout}" --type "Info"
webClose --name browser --leavebrowseropen
备注
如果直接为命令的超时参数设置了时间,那么设置超时不会对其进行变更。