跳到主要内容

setValue (设置值)

在清除输入框内容后,向元素发送一系列按键。如果元素不需要先清除,请使用 addValue

信息

如果您想使用特殊字符,例如从一个输入框复制粘贴值到另一个,请使用 keys 命令。

用法
$(selector).setValue(value)
参数
名称类型详情
valuestring, number要添加的值
示例
setValue.js
it('should set value for a certain element', async () => {
const input = await $('.input');
await input.setValue('test')
await input.setValue(123)

console.log(await input.getValue()); // outputs: '123'
});

Welcome! How can I help?

WebdriverIO AI Copilot