Files
cypress/docs/source/api/commands/submit.md
T

1.8 KiB

title, comments
title comments
submit false

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 %} Correct Usage

cy.get('form').submit()   // Submit a form

{% fa fa-exclamation-triangle red %} Incorrect 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().

Option Default Description
log true {% usage_options log %}
timeout {% url defaultCommandTimeout configuration#Timeouts %} {% usage_options timeout .submit %}

Yields {% helper_icon yields %}

{% yields same_subject .submit %}

Timeouts {% helper_icon timeout %}

.submit() will continue to try to submit the form for the duration of the {% url defaultCommandTimeout configuration#Timeouts %}.

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:

Command Log

When clicking on submit within the command log, the console outputs the following:

cy.submit console log

See also

  • {% url .click() click %}
  • {% url .type() type %}