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

isFocused

बताएं कि चयनित DOM-एलिमेंट में वर्तमान में फोकस है या नहीं। यदि सेलेक्टर कई एलिमेंट्स से मेल खाता है, तो यह true देगा यदि एलिमेंट्स में से एक में फोकस है।

उपयोग
$(selector).isFocused()
उदाहरण
index.html
<input name="login" autofocus="" />
hasFocus.js
it('should detect the focus of an element', async () => {
await browser.url('/');
const loginInput = await $('[name="login"]');
console.log(await loginInput.isFocused()); // outputs: false

await loginInput.click();
console.log(await loginInput.isFocused()); // outputs: true
})
रिटर्न्स
  • <Boolean> return: true यदि मेल खाने वाले एलिमेंट्स में से एक में फोकस है

Welcome! How can I help?

WebdriverIO AI Copilot