मुख्य सामग्री पर जाएं

चयनित है

यह 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