Method: Capybara::Node::Matchers#has_checked_field?

Defined in:
lib/capybara/node/matchers.rb

#has_checked_field?(locator = nil, **options, &optional_filter_block) ⇒ Boolean

Checks if the page or current node has a radio button or checkbox with the given label, value, id, or test_id attribute that is currently checked.

Parameters:

  • locator (String) (defaults to: nil)

    The label, name or id of a checked field

Returns:

  • (Boolean)

    Whether it exists



448
449
450
# File 'lib/capybara/node/matchers.rb', line 448

def has_checked_field?(locator = nil, **options, &optional_filter_block)
  has_selector?(:field, locator, **options.merge(checked: true), &optional_filter_block)
end