跳至主要內容

clearValue

清除輸入或文字區域元素的值。請確保在使用此命令之前可以與該元素互動。您無法清除已停用或處於唯讀模式的輸入元素。

用法
$(selector).clearValue()
範例
clearValue.js
it('should demonstrate the clearValue command', async () => {
const elem = await $('.input')
await elem.setValue('test123')

const value = await elem.getValue()
console.log(value) // returns 'test123'

await elem.clearValue()
value = await elem.getValue()
assert(value === ''); // true
})

歡迎!我能如何協助您?

WebdriverIO AI Copilot