跳至主要內容

waitForDisplayed

等待元素在指定的毫秒數內顯示或不顯示。

資訊

與其他元素指令相反,WebdriverIO 不會等待元素存在才執行此指令。

用法
$(selector).waitForDisplayed({ timeout, reverse, timeoutMsg, interval, withinViewport })
參數
名稱類型詳細資訊
options
選填
WaitForOptionswaitForDisplayed 選項 (選填)
options.timeout
選填
數字毫秒為單位 (預設值根據waitforTimeout 設定值)
options.reverse
選填
布林值如果為 true,則等待相反的結果 (預設值:false)
options.timeoutMsg
選填
字串如果存在,則覆寫預設錯誤訊息
options.interval
選填
數字檢查之間的間隔 (預設值:waitforInterval)
options.withinViewport
選填
布林值設定為 true 以等待元素在可視區域內顯示 (預設值:false)
範例
index.html
loading...
waitForDisplayedExample.js
loading...

歡迎!我能幫您什麼嗎?

WebdriverIO AI Copilot