getValue
取得由指定選擇器找到的 <textarea>
、<select>
或文字 <input>
的值。如果透過給定的選擇器找到多個元素,則會回傳一個值陣列。對於具有核取方塊或單選按鈕類型的輸入,請使用 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"
});