module Capybara::Node::Actions
def _check_with_label(selector, checked, locator,
def _check_with_label(selector, checked, locator, allow_label_click: session_options.automatic_label_click, **options) options[:allow_self] = true if locator.nil? synchronize(Capybara::Queries::BaseQuery.wait(options, session_options.default_max_wait_time)) do el = find(selector, locator, **options) el.set(checked) rescue StandardError => e raise unless allow_label_click && catch_error?(e) begin el ||= find(selector, locator, **options.merge(visible: :all)) unless el.checked? == checked el.session .find(:label, for: el, visible: true, match: :first) .click(**(Hash.try_convert(allow_label_click) || {})) end rescue StandardError # swallow extra errors - raise original raise e end end end