Interactor.js

Focused

The focused property returns a boolean value indicating whether the element has focus, which would be the document's current activeElement.

// only one element can have focus at a time
new Interactor('.name').focused //=> true
new Interactor('.email').focused //=> false

The property creator can be used with custom interactors to reflect whether a nested element has focus or not, and to make assertions against.

import interactor, { focused } from 'interactor.js';

@interactor class FieldInteractor {
  focused = focused('input');
}

new FieldInteractor('.field').focused //=> true/false

await new FieldInteractor('.field')
  .assert.not.focused()