# isFocused

Return true or false if the selected DOM-element currently has focus. If the selector matches multiple elements, it will return true if one of the elements has focus.

## Usage[​](#usage "Direct link to Usage")

```
await $(selector).isFocused()
```

## Examples[​](#examples "Direct link to Examples")

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
})
```

## Returns[​](#returns "Direct link to Returns")

* **\<Boolean>** **`return`:** true if one of the matching elements has focus
