Read more

Capybara: How to find the focused element

Emanuel De
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 online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show snapshot

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

Posted by Emanuel De to makandra dev (2023-09-07 09:29)