How to find out the currently focused DOM element with JavaScript

This works in all relevant browsers:


You can use this in your Selenium steps, for example, to assert that a form field is or is not focused.

Arne Hartherz over 8 years ago
This website uses short-lived cookies to improve usability.
Accept or learn more