Principle:Teamcapybara Capybara Form Submission
| Knowledge Sources | |
|---|---|
| Domains | Testing, Form_Interaction |
| Last Updated | 2026-02-12 00:00 GMT |
Overview
A form interaction pattern that submits forms by locating and clicking submit buttons using accessible identifiers.
Description
Form Submission simulates how a user submits a form: by clicking a button. The :button selector finds buttons by their id, name, test_id, value, title, or visible text content — matching <button>, <input type="submit">, <input type="image">, <input type="button">, and ARIA role="button" elements.
This is deliberately limited to button-clicking (not programmatic form submission) because it most closely matches real user behavior.
Usage
Use click_button after filling in form fields. The button is found semantically — by its visible text, value attribute, or accessible name.
Theoretical Basis
# Abstract submission flow (not actual code)
click_button(locator):
button = find(:button, locator)
button.click # triggers native form submission
return button