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!
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
Will Lam
7,027 PointsCapybara: 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
4 Answers

Matthew Reed
Courses Plus Student 17,986 PointsI'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

Clair Griffiths
10,158 PointsThat would have taken me HOURS to figure out, thank you!

Matthew Reed
Courses Plus Student 17,986 PointsNo problem. Glad it helped!

Nelly Lam
5,098 PointsI 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) %>">

Louis Magnotti
4,402 PointsWOW. Saved my life. Thank you.

NIKHIL MISHRA
5,378 PointsI m extremely thankful to you :)

Matej Lukášik
27,440 PointsI 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 ;-)

Brandon Barrette
20,485 PointsDid 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.

Will Lam
7,027 PointsThanks 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) %>">
José Villalobos
Courses Plus Student 1,593 PointsJosé Villalobos
Courses Plus Student 1,593 PointsI 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?