Posted 3 months ago. Visible to the public.

Capybara: How to find a hidden field by its label

To find an input with the type hidden, you need to specify the type hidden:

Copy
find_field('Some label', type: :hidden)

Otherwise you will see an exception :

Copy
find_field('Some label') # => Capybara::ElementNotFound: Unable to find field "Some label" that is not disabled`.

Note: Usually you don't need to check the input of hidden fields in an integration test. But e.g. waiting for a datepicker library to write the expected value to this field before continuing the test, which prevents flaky tests, is a valid use case.

makandra has been working exclusively with Ruby on Rails since 2007. Our laser focus on a single technology has made us a leader in this space.

Owner of this card:

Avatar
Emanuel De
Last edit:
2 months ago
by Niklas Hasselmeyer
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Emanuel De to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more