Add test for clicking label of a blocked element

This commit is contained in:
Ian Lesperance 2018-07-19 17:09:45 -04:00
parent d613fd572a
commit f99866a984
2 changed files with 13 additions and 0 deletions

View File

@ -195,6 +195,13 @@ Capybara::SpecHelper.spec '#check' do
@session.click_button('awesome')
expect(extract_results(@session)['cars']).to include('pagani')
end
it 'should check via the label if input is visible but blocked by another element' do
expect(@session.find(:checkbox, 'form_cars_bugatti', unchecked: true, visible: :all)).to be_truthy
@session.check('form_cars_bugatti', allow_label_click: true)
@session.click_button('awesome')
expect(extract_results(@session)['cars']).to include('bugatti')
end
end
end
end

View File

@ -185,6 +185,12 @@ New line after and before textarea tag
<label for="form_cars_ferrari">Ferrari</label>
<input type="checkbox" value="pagani" name="form[cars][]" id="form_cars_pagani" style="position: absolute; left: -9999px"/>
<label for="form_cars_pagani">Pagani</label>
<div style="position: relative;">
<input type="checkbox" value="bugatti" name="form[cars][]" id="form_cars_bugatti"/>
<div style="position: absolute; top: 0; right: 0; bottom: 0; left: 0; background-color: #fff;">
<label for="form_cars_bugatti">Bugatti</label>
</div>
</div>
<input type="checkbox" value="ariel" name="form[cars][]" id="form_cars_ariel" style="display: none"/>
<input type="checkbox" value="porsche" name="form[cars][]" id="form_cars_porsche" checked="checked" style="display: none"/>
<label>