Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8963075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:16:48+00:00 2026-06-15T16:16:48+00:00

I have been trying to set up Capybara to test a form but I

  • 0

I have been trying to set up Capybara to test a form but I keep getting the error
cannot fill in, no text field, text area or password field with id, name, or label 'Name' found

Here is what I have in my view:

<%= form_for(@user) do |f| %>
  <%= f.label :name %>
  <%= f.text_field :name %>
  ...
  <%= f.submit "Create Account", class: "btn btn-large btn-primary" %>
<% end %>

which renders the following html:

<label for="user_name">Name</label>
<input id="user_name" name="user[name]" size="30" type="text" />

So it seems like it should be finding the field based on the label.

Here is what my user_pages_test.rb file has (I am using Test::Unit and shoulda-context):

context "sign up page" do
  should "add user to database when fields are filled in" do
    fill_in "Name", with: "Bubbles"
    ...
    click_button "Create Account"
  end
end

Here is what I’ve tried so far:

1) changing the call to fill_in to match the id with fill_in "user_name", with: "Bubbles"
2) changing the call to fill_in to page.fill_in "Name", with: "Bubbles" to match the example in the documentation
3) changing the view to manually add the id "Name" with <%= f.text_field :name, id: "Name" %> (this answer)
4) changing the call to get sign_up_path to get "/sign_up" (in case it was an issue with the routing)

All these still give me the same error, which makes me think that the page isn’t being loaded correctly for some reason. However, I have a different (passing) test in the same context that asserts the page has the correct title, so I know the page does get loaded correctly (in the setup).

Based on this (and according to this answer), it seems like the problem might just be that the fill_in method isn’t waiting for the page to load before trying to access the fields. According to this suggestion, I added the line puts page.body in my test to see that the HTML was being loaded completely before it was trying to fill in the fields, and got the following output:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">

So, I was pretty sure that fill_in just wasn’t waiting for the page to load. I then tried

5) changing the Capybara.default_wait_time according to this answer, but this had no effect. I tried setting it in the ActionDispatch::IntegrationTest class in the test_helper file (where Capybara is included), and also in the test itself.

Then I tried adding puts page.body in the passing test (both before and after it asserts the correct title), and I got the same output. THEN, I found this answer, and finally got the console to print out the page’s HTML. I tried one more thing to get Capybara to fill in the fields:

6) changed the call to fill_in to say @response.fill_in, since @response seems to do what I thought the page variable was supposed to do.

So, I have two questions about this:

1) What does the page variable actually refer to? The doctype declaration for my app is just <!DOCTYPE html>, so I have no idea where it gets the old one from.

2) Why isn’t Capybara able to find/fill_in these fields?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T16:16:48+00:00Added an answer on June 15, 2026 at 4:16 pm

    You need to use the visit method to get the page object setup properly. The capybara documentation indicates that ‘/’ is visited by default and if you want to visit some other page you need to do an explicit call. It may also be helpful to read a bit about the difference between visit and get.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to set AlarmManager for Specific date, but it is not
I have been trying to set-up Maven for use in our dev department but
I have been trying to get a progressbar set to marquee to keep moving
I have been trying to graph my data set using GNUPLOT, but so far
I have been trying to set a widget's window to fullscreen. I tried getting
I have been trying to set a custom resourceProviderFactory at the web.config file but
I have been trying to restrict the password field with a set of characters.
We have been trying to analyse this exception: Message: Error: Object reference not set
I have been trying to set up Eclipse and the Arduino libraries. I have
I have been trying to set the scroll of my page to a certain

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.