<commit_before>slug: submit
excerpt: Submit a form

Submits the DOM element from the previous command if it is a form. Submit can only be called on a single form.

**The following events are fired during submit:** `submit`

| | |
|--- | --- |
| **Returns** | the new DOM element(s) found by the command. |
| **Timeout** | `cy.submit` will retry for the duration of the [`commandTimeout`](https://on.cypress.io/guides/configuration#section-global-options). |

***

# [cy.submit()](#section-usage)

Submit a form.

***

# Options

Pass in an options object to change the default behavior of `cy.submit`.

**cy.submit( *options* )**

Option | Default | Notes
--- | --- | ---
`log` | `true` | Display command in command log

***

# Usage

## Submit a form

```html
<form id="contact">
  <input type="text" name="message">
  <button type="submit">Send</button>
</form>
```

```javascript
// submits the form and performs all default actions
// returns <form> for further chaining
cy.get("#contact").submit()
```

***

# Command Log

## Submit a form

```javascript
cy.route("POST", /users/, "fixture:user").as("userSuccess")
cy.get("form").submit()
```

The commands above will display in the command log as:

<img width="594" alt="screen shot 2015-11-29 at 1 21 43 pm" src="https://cloud.githubusercontent.com/assets/1271364/11459081/3149d9e6-969c-11e5-85b2-ba57638f02df.png">

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

<img width="547" alt="screen shot 2015-11-29 at 12 42 22 pm" src="https://cloud.githubusercontent.com/assets/1271364/11458858/b30b0a0a-9696-11e5-99b9-d785b597287c.png">

***

# Related

- [click](https://on.cypress.io/api/click)<commit_msg>fixed incorrect console.log image on submit() command<commit_after>slug: submit
excerpt: Submit a form

Submits the DOM element from the previous command if it is a form. Submit can only be called on a single form.

**The following events are fired during submit:** `submit`

| | |
|--- | --- |
| **Returns** | the new DOM element(s) found by the command. |
| **Timeout** | `cy.submit` will retry for the duration of the [`commandTimeout`](https://on.cypress.io/guides/configuration#section-global-options). |

***

# [cy.submit()](#section-usage)

Submit a form.

***

# Options

Pass in an options object to change the default behavior of `cy.submit`.

**cy.submit( *options* )**

Option | Default | Notes
--- | --- | ---
`log` | `true` | Display command in command log

***

# Usage

## Submit a form

```html
<form id="contact">
  <input type="text" name="message">
  <button type="submit">Send</button>
</form>
```

```javascript
// submits the form and performs all default actions
// returns <form> for further chaining
cy.get("#contact").submit()
```

***

# Command Log

## Submit a form

```javascript
cy.route("POST", /users/, "fixture:user").as("userSuccess")
cy.get("form").submit()
```

The commands above will display in the command log as:

<img width="594" alt="screen shot 2015-11-29 at 1 21 43 pm" src="https://cloud.githubusercontent.com/assets/1271364/11459081/3149d9e6-969c-11e5-85b2-ba57638f02df.png">

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

![cy.submit console log](https://cloud.githubusercontent.com/assets/1271364/12888878/222f5522-ce4a-11e5-9edd-f67be2ebce40.png)

***

# Related

- [click](https://on.cypress.io/api/click)
{'fraction_non_alphanumeric': 0.164802825191289, 'fraction_numerical': 0.05679811653914067, 'mean_word_length': 4.237288135593221, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5005923', 'n_tokens_mistral': 1257, 'n_tokens_neox': 1129, 'n_words': 335}