Capybara have_field not finding field found by have_selector
The problem is that the textarea has the disabled="disabled"
attribute, meaning it is a disabled field. By default, Capybara ignores disabled fields. New in Capybara 2.1 is the option to look for disabled fields.
Adding the disabled: true
option will solve your problem:
expect(page).to have_field(id, type: 'textarea', disabled: true)
Note:
- That when you include
disabled: true
, the field must be disabled. The default isdisabled: false
, which only matches fields that are not disabled. - That the :type value should be a string. As seen in the above, it is
type: 'textarea')
. Using a symbol,type: :textarea
will not work.