Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Capybara: ElementNotFound: Unable to find css "todo_list_1"

Hey folks,

I've been following along the Rails 4 Todo list app project.

I've been trying to follow along and somewhere along the way I must have forgotten or misplaced a semi colon or something along those lines.

I'm getting errors left right and center as you can see in my subject line.

Here's a screenshot of my error right now - I don't believe the tests in r spec are the issue, it's more that capybara can't find the CSS and I'm not sure where exactly I went wrong.

Halp!

Here's the screenshot screenshot

I got this same issue when I look into the inspect element I can find my ids so in the test this ids should be printing. Has anyone gone through this?

4 Answers

I'm sure if you figured this out but I was having the same issue until I realized that in the edit_spec.rb file, I forgot to put a pound sign in front of the todo_list_id. So I had:

within "todo_list_#{todo_list.id}" do

when it should have been:

within "#todo_list_#{todo_list.id}" do

That would have taken me HOURS to figure out, thank you!

No problem. Glad it helped!

I had the same error message, but I found out I was missing the "=" within the erb tag within the index.html.erb file.

<tr id="<%= dom_id(todo_list) %>">

WOW. Saved my life. Thank you.

I m extremely thankful to you :)

I had the same error message but in the end I found out the problem was I did not create and sign in a user before running the test which was the point of the video :-D So even though the help guys suggest here is right, you might still get the same error message if you do not sign in a user, since the lists won't be displayed while the user is not signed in, thus there won't be any "#todo_list_1" on the page ;-)

Did you remember to add the id element to the HTML? There should be a

<li id = "<%= dom_id(todo_list) %>">

That then adds the id="todo_list_1" which capybara is trying to look for.

Thanks for replying Brandon

the only thing I was able to find that was almost matched the id element was line 14 in app/views/todo_lists/index.html.erb which looked like this:

<tr id="<%= dom_id(todo_list) %>">