jeudi 7 mai 2015

Capybara check if selector is on page

I want to test with Capybara if I have a selector on a page. The selector is contained in a form as such:

<%=form_for @currency.neural_network do |f| %>
    <%= f.label "Days" %>
    <%= f.select(:prediction_days, [1..30]) %>
    <%= f.submit "Predict", class: "btn btn-primary" %>
<% end %>

I'm not sure however how to name the selector such that I can verify its existence with Capybara. I want to do something like this:

<%=form_for @currency.neural_network do |f| %>
    <%= f.label "Days" %>
    <div id="select_days" >
    <%= f.select(:prediction_days, [1..30]) %>
    </div>
    <%= f.submit "Predict", class: "btn btn-primary" %>
<% end %>

And test it somehow like this:

expect(page).to have_selector('select_days')

Aucun commentaire:

Enregistrer un commentaire