Improve this doc

Clear the value of an input or textarea.

An alias for .type({selectall}{backspace})




Correct Usage

cy.get('[type="text"]').clear()        // Clear text input
cy.get('textarea').type('Hi!').clear() // Clear textarea
cy.focused().clear()                   // Clear focused input/textarea

Incorrect Usage

cy.clear()                // Errors, cannot be chained off 'cy'
cy.get('nav').clear()     // Errors, 'get' doesn't yield input or textarea
cy.url().clear()          // Errors, 'url' doesn't yield DOM element


options (Object)

Pass in an options object to change the default behavior of .clear().

Option Default Description
log true Displays the command in the Command Log
force false Forces the action, disables waiting for actionability
timeout defaultCommandTimeout Time to wait for .clear() to resolve before timing out


  • .clear() yields the same subject it was given from the previous command.


No Args

Clear the input and type a new value.

cy.get('textarea').clear().type('Hello, World')



The element must first reach actionability

.clear() is an “action command” that follows all the rules defined here.


.clear() is just an alias for .type({selectall}{backspace}).

Please read the .type() documentation for more details.



  • .clear() requires being chained off a command that yields DOM element(s).

  • .clear() requires the element to be an input or textarea.


  • .clear() will automatically wait for the element to reach an actionable state.

  • .clear() will automatically wait for assertions you've chained to pass.


  • .clear() can time out waiting for the element to reach an actionable state.

  • .clear() can time out waiting for assertions you've added to pass.

Command Log

Clear the input and type a new value

cy.get('input[name="name"]').clear().type('Jane Lane')

The commands above will display in the command log as:

Command log for clear

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

console.log for clear

See also