Fill in the field without a label

I have a text box like this:

<%= form_for(ownership, remote: true) do |f| %> <div> <%= f.text_field :confirm, value: nil, title: t('label.transaction.confirmation.code') %> <%= f.hidden_field :start_date, value: Time.now %> </div> <%= f.submit t('button.ownership.take.confirmation'), class: "btn btn-small"%> <% end %> 

And I want to fill in the rspec text box:

 fill_in t('label.transaction.confirmation.code'), with: "something" 

But this does not work, because rspec does not recognize the header tag to fill the text box:

 Failure/Error: fill_in t('label.transaction.confirmation.code'), with: confirmation_code Capybara::ElementNotFound: Unable to find field "Code de confirmation" 

Do you know how to fill an rspec text field without adding a label?

+4
source share
1 answer

The first argument to the fill_in method must be selected by css. for example: #id , li , .class .

So you can change t('label.transaction.confirmation.code')

in the id text field or [title='#{t('label.transaction.confirmation.code')}']

eg.

 <input id="conf_code"> fill_in 'conf_code', with: 'something' 
+3
source

Source: https://habr.com/ru/post/1498132/


All Articles