samedi 18 mars 2017

Haml checkbox cannot be detected using capybara page.has_checked_field?

here is my code in haml %input{:type=>"checkbox", :checked=>true } %label Checkbox enter image description here

it looks like this here is the test code expect(page).to have_checked_field('Checkbox')

however, test failed because: Failure/Error: expect(page).to have_field('Checkbox', checked:true) expected to find field "Checkbox" that is checked but there were no matches

running this line produces the similar error: expect(page).to have_css('checkbox')

annoyingly, this line is fine: expect(page).to have_css('input')

could someone please tell me how am I supposed to write a checkbox that can be detected by rspec or how to modify my testing to be able to detect the checkbox? I saw some suggestions for using 'find(:css ...', if I take that suggestion, then what would be the purpose of the method 'have_checked_field('Checkbox')'? which could be found in capybara documentation. http://ift.tt/2nl6uxi




Aucun commentaire:

Enregistrer un commentaire