Aller au contenu principal

isSelected

Retourne vrai ou faux selon qu'un élément <option> ou <input> de type case à cocher ou bouton radio est actuellement sélectionné.

Utilisation
$(selector).isSelected()
Exemples
index.html
<select name="selectbox" id="selectbox">
<option value="John Doe">John Doe</option>
<option value="Layla Terry" selected="selected">Layla Terry</option>
<option value="Bill Gilbert">Bill Gilbert"</option>
</select>

isSelected.js
it('should detect if an element is selected', async () => {
let element = await $('[value="Layla Terry"]');
console.log(await element.isSelected()); // outputs: true

element = await $('[value="Bill Gilbert"]')
console.log(await element.isSelected()); // outputs: false
});
Retourne
  • <Boolean> return: vrai si l'élément est sélectionné

Welcome! How can I help?

WebdriverIO AI Copilot