Vai al contenuto principale

getValue

Ottieni il valore di un <textarea>, <select> o di un <input> di testo trovato tramite il selettore specificato. Se vengono trovati più elementi tramite il selettore specificato, viene restituito un array di valori. Per input con tipo checkbox o radio, utilizza isSelected.

Utilizzo
$(selector).getValue()
Esempi
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"
});
Restituisce
  • <String> return: valore dell'elemento/i richiesto

Welcome! How can I help?

WebdriverIO AI Copilot