Posted over 8 years ago. Visible to the public. Linked content.

How to find out the currently focused DOM element with JavaScript

This works in all relevant browsers:

Copy
document.activeElement

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

Your development team has a full backlog of feature requests, chores and refactoring coupled with deadlines? We are familiar with that. With our "DevOps as a Service" offering, we support developer teams with infrastructure and operations expertise.

Owner of this card:

Avatar
Arne Hartherz
Last edit:
over 8 years ago
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Arne Hartherz to makandra dev
This website uses short-lived cookies to improve usability.
Accept or learn more