Перейти до основного вмісту

isSelected

Поверне true або false залежно від того, чи вибраний в даний момент елемент <option> або <input> типу checkbox або radio.

Використання
$(selector).isSelected()
Приклади
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
});
Повертає
  • <Boolean> return: true якщо елемент вибраний

Welcome! How can I help?

WebdriverIO AI Copilot