获取值
获取通过给定选择器找到的 <textarea>
、<select>
或文本 <input>
的值。
如果通过给定选择器找到多个元素,则返回值数组。
对于带有checkbox或radio类型的输入,请使用isSelected。
用法
$(selector).getValue()
示例
index.html
<input type="text" value="John Doe" id="username">
getValue.js
it('should demonstrate the getValue command', async () => {
const inputUser = await $('#username');
const value = await inputUser.getValue();
console.log(value); // outputs: "John Doe"
});
返回值
- <String>
return
: 请求元素的值