Hello.
There is the following test fragment:
require 'rails_helper' describe 'A contract' do before do @project = create(:project) @client = @project.user @contractor = create(:contractor) @contractor.contractor_info = create(:contractor_info) @contractor.contractor_info.source_languages << @project.source_languages @contractor.contractor_info.target_languages << @project.target_languages sign_in_contractor(@contractor) visit project_url(id: @project) page.find("#newProposal").click #click_link("Post Proposal") expect(current_path).to eq(new_project_proposal_path(project_id: @project.slug)) fill_in 'Amount', with: 50 fill_in I18n.t('proposals.new.description_placeholder'), with: 'X' * 60 click_button 'Post Proposal' expect(current_path).to eq(project_path(id: @project)) @proposal = @project.proposals.last log_out(@contractor) end ................................................................................
on the line page.find("#newProposal").click
shows the error ElementNotFound: Unable to find css "#newProposal"
On the projects / show view there is this link with the given id:
<% if contractor_signed_in? %> <% if policy(Proposal).create? && @project.available? %> <div class="col-md-4"> <%= link_to new_project_proposal_path(@project), class: "btn btn-lg btn-primary btn-block", id: "newProposal" do %> <span class="icon icon-plus pull-left mb"></span><%= t('proposals.new_proposal') %> <% end %> </div> <% end %> <div class="col-md-4 pull-right"> <div class="panel panel-default mb"> <div class="panel-body"> <h4><%= t('sidebar.about_client') %></h4> <p><strong><%= t('user.name') %>:</strong> <%= @project.user.fullname %></p> <p><strong>First_name:</strong></p> <p><strong><%= t('projects.projects_posted') %>:</strong> <%= @project.user.projects.size %></p> </div> </div> </div> <% end %>
I put brekpoint in the test before clicking the link. Checking current_path is "/ projects / translation1-048fc3". We are on the project page, as it should be.
Why doesn’t the capybara see this link? Thanks in advance for your reply.
if
because of which the link may not be shown at all. 2. If it, nevertheless, is in html, is it not hidden by such styles? - anoamhtml
method. If it is more convenient, you can usesave_page
orsave_and_open_page
. Just in case, here is the link to the documentation - anoam