Method: Capybara::Node::Finders#find_field

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

#find_field([locator], **options) ⇒ Capybara::Node::Element

Find a form field on the page. The field can be found by its name, id or label text.

If the driver is capable of executing JavaScript, this method will wait for a set amount of time and continuously retry finding the element until either the element is found or the time expires. The length of time this method will wait is controlled through default_max_wait_time.

Parameters:

  • locator (String)

    name, id, test_id attribute, placeholder or text of associated label element

Options Hash (**options):

  • wait (false, true, Numeric)

    Maximum time to wait for matching element to appear. Defaults to default_max_wait_time.

  • checked (Boolean)

    Match checked field?

  • unchecked (Boolean)

    Match unchecked field?

  • disabled (Boolean, Symbol) — default: false

    Match disabled field?

    • true - only finds a disabled field
    • false - only finds an enabled field
    • :all - finds either an enabled or disabled field
  • readonly (Boolean)

    Match readonly field?

  • with (String, Regexp)

    Value of field to match on

  • type (String)

    Type of field to match on

  • multiple (Boolean)

    Match fields that can have multiple values?

  • id (String, Regexp)

    Match fields that match the id attribute

  • name (String)

    Match fields that match the name attribute

  • placeholder (String)

    Match fields that match the placeholder attribute

  • class (String, Array<String>, Regexp)

    Match fields that match the class(es) passed

Returns:



135
136
137
# File 'lib/capybara/node/finders.rb', line 135

def find_field(locator = nil, **options, &optional_filter_block)
  find(:field, locator, **options, &optional_filter_block)
end