Capybara testing value of hidden field
just do this:
find("#id_of_hidden_input", :visible => false).value
the matcher has_field?
works with hidden fields as well. no need to do weird gymnastics with find
or all
in this context.
page.has_field? "label of the field", type: :hidden, with: "field value"
page.has_field? "id_of_the_field", type: :hidden, with: "field value"
the key here is setting the :type
option to :hidden
explicitly.
why use a label with a hidden field? this comes in handy if you're using a js library, like flatpickr, that cloaks your original text field to hide it. not coupling your behavior tests to specific markup is always a good thing.