I am currently writing a Cucumber function for a messaging system in a Rails application. This is one of my steps.
Then(/^they should see the message displayed in their language$/) do id = "message_to_#{@family.id}" expect(page).to have_selector("textarea##{id}") save_and_open_page expect(page).to have_field(id, type: :textarea) end
The first statement passes, but the second fails. When I check the markup created using save_and_open_page, the following element is present:
<textarea cols="22" disabled="disabled" id="message_to_13" name="body" placeholder="Hallo, Ich bin sehr interessiert an deinem Profil. WΓΌrdest du gerne mit mir in Kontakt treten?" rows="7"></textarea>
The error message displayed for the second test:
expected to find field "message_to_13" but there were no matches. Also found "", which matched the selector but not all filters. (Capybara::ExpectationNotMet)
I am tearing my hair off here to understand why Capybara can find this element that is explicitly present using has_selector but not with has_field?
source share