Files
cypress/docs/source/api/commands/submit.md
T
2017-06-24 15:54:35 -04:00

1.6 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 %} 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 {% helper_icon yields %}

.submit() yields the form that was submitted.

Timeout {% 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 %}