メインコンテンツにスキップ

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"
});
戻り値
  • <String> return: リクエストされた要素の値

Welcome! How can I help?

WebdriverIO AI Copilot