Read more

Capybara: How to find a hidden field by its label

Emanuel
March 17, 2020Software engineer at makandra GmbH

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

find_field('Some label', type: :hidden)
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

Otherwise you will see an exception :

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.

Posted by Emanuel to makandra dev (2020-03-17 17:37)