waitForClickable
等待元素在指定的毫秒數內可點擊或不可點擊。
資訊
與其他元素命令相反,WebdriverIO 不會等待元素存在才執行此命令。
用法
$(selector).waitForClickable({ timeout, reverse, timeoutMsg, interval })
參數
名稱 | 類型 | 詳細資訊 |
---|---|---|
options 選填 | WaitForOptions | waitForEnabled 選項(選填) |
options.timeout 選填 | 數字 | 毫秒為單位的時間(預設值根據 waitforTimeout 設定值) |
options.reverse 選填 | 布林值 | 如果為 true,則等待相反的狀態(預設值:false) |
options.timeoutMsg 選填 | 字串 | 如果存在,則會覆寫預設錯誤訊息 |
options.interval 選填 | 數字 | 檢查之間的間隔(預設值:waitforInterval ) |
範例
waitForClickable.js
it('should detect when element is clickable', async () => {
const elem = await $('#elem')
await elem.waitForClickable({ timeout: 3000 });
});
it('should detect when element is no longer clickable', async () => {
const elem = await $('#elem')
await elem.waitForClickable({ reverse: true });
});