What is the difference between Rspec have_css, have_selector, and have_field? -
i have html.erb rails form:
<h1 class=new_vendor_header>new vendor form</h1> <%= form_for(@vendor) |f| %> <%= f.label :name %> <%= f.text_field :name, placeholder: "ex: jeff" %> <%= f.submit "submit" %> <% end %> this passes:
expect(page).to have_selector('input[placeholder="ex: jeff"]') but not:
expect(page).to have_field('input[placeholder="ex: jeff"]') and not:
expect(page).to have_selector('input[placeholder="ex: jeff"]') selector refers html selector right refers html elements? have_css thought looked css seems more. here example cheat sheet:
response.body.should have_css("input", :count => 3) #true if there 3 input tags in response and seems input html selectors.
so difference , why other 2 fail in example?
from docs here have_css call has_selector css param, has_selector can handle css, xpath, ...
def have_css(css, options={}) haveselector.new(:css, css, options) end
Comments
Post a Comment