Method: Capybara::Node::Actions#fill_in
- Defined in:
- lib/capybara/node/actions.rb
#fill_in([locator], with: , **options) ⇒ Capybara::Node::Element
Locate a text field or text area and fill it in with the given text. The field can be found via its name, id, test_id attribute, placeholder, or label text. If no locator is provided this will operate on self or a descendant.
# will fill in a descendant fillable field with name, id, or label text matching 'Name'
page.fill_in 'Name', with: 'Bob'
# will fill in `el` if it's a fillable field
el.fill_in with: 'Tom'
88 89 90 91 92 |
# File 'lib/capybara/node/actions.rb', line 88 def fill_in(locator = nil, with:, currently_with: nil, fill_options: {}, **) [:with] = currently_with if currently_with [:allow_self] = true if locator.nil? find(:fillable_field, locator, **).set(with, **) end |