Reputation: 3583
page source (from save_and_open_page):
<a class="btn btn-mini btn-danger" data-confirm="Are you sure?" data-method="delete" href="/slides/1" rel="nofollow">Delete</a>
spec/features/slides_spec.rb:
scenario "Delete slide" do
visit album_slides_url slide.album
# save_and_open_page
expect{page.find('btn btn-mini btn-danger').click}.to change(Slide, :count).by(-1)
end
error:
Unable to find css "btn btn-mini btn-danger"
There are a few Q&A for similar issue but I didn't find any solution there. Any ideas ?
Upvotes: 0
Views: 1312
Reputation: 53018
Alternatively, you could also use
expect{click_link('Delete')}.to change(Slide, :count).by(-1)
Its much simpler to find the text
i.e., Delete
in this case of an anchor
element (..) and fire click_link
event on it.
Upvotes: 1
Reputation: 1711
In CSS selectors classes are identified by starting with dots, easy to forget. Also, if you want to find an element which has all of the classes specified you can't have any whitespace in between them; otherwise it is looking for children.
page.find('.btn.btn-mini.btn-danger')
Upvotes: 2