Files
cypress/docs/source/api/commands/submit.md
T
Loren Norman f947e0c55d Merge remote-tracking branch 'origin/master'
# Conflicts:
#	docs/source/guides/getting-started/installing-cypress.md
2017-06-13 15:49:54 -04:00

1.7 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

.submit() yields the form that was submitted.

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:

screen shot 2015-11-29 at 1 21 43 pm

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