mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-20 22:21:23 -06:00
1.7 KiB
1.7 KiB
title, comments, description
| title | comments | description |
|---|---|---|
| submit | true |
Submit a form.
Syntax
.submit()
.submit(options)
Usage
.submit() requires being chained off another cy command that yields a form.
{% fa fa-check-circle green %} Valid Usage
cy.get('form').submit() // Submit a form
{% fa fa-exclamation-triangle red %} Invalid Usage
cy.submit() // Errors, cannot be chained off 'cy'
cy.get('input').submit() // Errors, 'input' does not yield a form
Arguments
{% fa fa-angle-right %} options (Object)
Pass in an options object to change the default behavior of .submit().
Yields
.submit() yields the form that was submitted.
Timeout
.submit() will continue to try to submit the form for the duration of the defaultCommandTimeout
Example
Submit a form
Submit can only be called on a single form.
<form id="contact">
<input type="text" name="message">
<button type="submit">Send</button>
</form>
cy.get('#contact').submit()
Command Log
Submit a form
cy.route('POST', '/users', 'fixture:user').as('userSuccess')
cy.get('form').submit()
The commands above will display in the command log as:
When clicking on submit within the command log, the console outputs the following:
