I
I
IvanN7772015-08-05 08:57:44
Ruby on Rails
IvanN777, 2015-08-05 08:57:44

When using fill_in Capybara, the field is not filled, what's wrong?

To study integration tests, I began to use this stone.
I connected it, but when the user fills out the form, the test does not pass.

visit  new_user_path
fill_in 'Email', :with => '[email protected]'
click_button 'New user'
expect(page).to have_content 'Success'

In order to eliminate errors, only email has become a mandatory field in the model.
Then I decided to make a user form where email is filled in by default and removed fill_in
visit  new_user_path
click_button 'New user'
expect(page).to have_content 'Success'

Everything went fine, from this I concluded that the problem was with him.
Label c 'Email' exists, tried to use an identifier by id, but in vain
Then a slightly more clumsy approach (well, it seemed to me)
find('#user_email').set('[email protected]')
The test still refuses to pass.
Decided to use a launchy stone
and put it like this
visit  new_user_path
click_button 'New user'
save_and_open_page
expect(page).to have_content 'Success'

I expected to get debug information in the browser (there is my form screen), but I didn't get anything.
Perhaps not in the browser should output debugging.
I realized that fill_in does not work even before that.
What needs to be written in the Mumps config so that it fills in the fields?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel Kononenko, 2015-08-05
@IvanN777

Connect with IDs.
For example, in the case of a device:
fill_in 'user_email', :with => '[email protected]'

I
IvanN777, 2015-08-05
@IvanN777

My problem was in cleaning the test database, I didn’t miss the same email) sorry

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question