Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | 1x | /** * * 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. * * <example> :index.html <input name="login" autofocus="" /> :hasFocus.js it('should detect the focus of an element', () => { browser.url('/'); const loginInput = $('[name="login"]'); console.log(loginInput.isFocused()); // outputs: false loginInput.click(); console.log(loginInput.isFocused()); // outputs: true }) * </example> * * @alias element.isFocused * @return {Boolean} true if one of the matching elements has focus * * @uses protocol/execute * @type state * */ import { ELEMENT_KEY } from '../../constants' import { getBrowserObject } from '../../utils' import isFocusedScript from '../../scripts/isFocused' export default function isFocused () { return getBrowserObject(this).execute(isFocusedScript, { [ELEMENT_KEY]: this.elementId, // w3c compatible ELEMENT: this.elementId // jsonwp compatible }) } |