Skip to content

Commit

Permalink
Merge pull request #2071 from elliterate/chores/improve-not-interacta…
Browse files Browse the repository at this point in the history
…ble-checkbox-test

Add test for clicking label of a blocked element
  • Loading branch information
twalpole authored Jul 19, 2018
2 parents e65182a + f99866a commit d386f3e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/capybara/spec/session/check_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,13 @@
@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
Expand Down
6 changes: 6 additions & 0 deletions lib/capybara/spec/views/form.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit d386f3e

Please sign in to comment.