跳到主要内容

等待元素显示

等待元素在指定的毫秒数内显示或不显示。

信息

与其他元素命令不同,WebdriverIO 不会等待元素存在才执行此命令。

用法
$(selector).waitForDisplayed({ timeout, reverse, timeoutMsg, interval, withinViewport })
参数
名称类型详情
options
可选
WaitForOptionswaitForDisplayed 选项(可选)
options.timeout
可选
Number毫秒时间(默认基于 waitforTimeout 配置值设置)
options.reverse
可选
Boolean如果为 true,则等待相反的情况(默认值:false)
options.timeoutMsg
可选
String如果存在,它会覆盖默认的错误消息
options.interval
可选
Number检查之间的间隔(默认值:waitforInterval
options.withinViewport
可选
Boolean设置为 true 以等待元素在视口内显示(默认值:false
示例
index.html
loading...
waitForDisplayedExample.js
loading...
返回值
  • <Boolean> return: 如果元素显示(或者如果标志设置为相反情况则不显示)返回 true

Welcome! How can I help?

WebdriverIO AI Copilot