Read more

Capybara: How to find the focused element

Emanuel
September 07, 2023Software engineer at makandra GmbH

Capybara allows you to filter elements that are focused.

page.find(:fillable_field, focused: true) # Filtering only fillable inputs for performance reasons
page.find(:xpath, '//*', focused: true) # Filter all fields

Legacy approach

Illustration UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
Read more Show archive.org snapshot

In older version, it was possible to use the :focus pseudo-class. This seems not to work in newer versions anymore.

find(':focus')
Posted by Emanuel to makandra dev (2023-09-07 09:29)