I am writing feature tests for my Rails 5 application. One feature is the ability to click a link with method POST.
visit "/admin/client_servers/#{client_server.id}"
click_on('Request Review From Application Owner')
I receive the error "Capybara::ElementNotFound: Unable to find link or button 'Request Review From Application Owner'"
Just experimenting, I check to see if the test can find any element I know is on the screen. I have one container div with a class of 'description' and the test is unable to find the element.
The previous test passes
visit "/admin/client_servers/#{client_server.id}"
expect(page).to have_text("Request Review From Application Owner")
So I know the text I want to click on appears on the page. My html is setup:
<div class="mark-ready-btn server-button" id="overall-tab" data-param="overall">
<%=link_to admin_client_servers_update_review_status_path(status: 1, id: @server.id), class: "request-review-btn", method: 'POST' do%>
<div class="server-mark-ready" id="overall-tab" data-param="overall">
Request Review From Application Owner
</div>
<%end%>
</div>
I've checked but the test is unable to find the css tags '.mark-ready-btn server-button', '.request-review-btn', or '.server-mark-ready'. I've searched this problem online and looked into Capybara and Rspec documentation. Is there something I'm missing or a improper syntax I've written in the test? I'd appreciate any help on this issue.
click_link
instead ofclick_on
? See this answer for detailed explaination stackoverflow.com/a/17564749/1202324 . Since you have adiv
inside of youra
capybara could be confused and does not see it as a link or button. – Denny Muellerpage.html
and find the relevant part of the actual HTML that is being processed and add that to your question. – Thomas Walpoleid=overall-tab
you have your divfind("#overall-tab").click
– johan