Skip to main content

Cypress Clear Command

Clear command in Cypress is an action command that clears the value of an input or textarea. This command is an alias for 




Arguments Used In Clear Command

Options (Object): Can pass in objects to change the default behavior of .type(). Here is the list of some of the options that Cypress can use with the type command:

  1. animationDistanceThreshold: Used to consider the distance between the pixels and the element and that mist exceeds over time. Default is animationDistanceThreshold.
  2. force: Forces the action. Default is false.
  3. log: Displays the record in command log in output. Default is true.
  4. scrollBehavior: This is used to viewport position where an element should be scrolled before the command execution. Default is ScrollBehaviour.
  5. timeout: Used to input time to wait for the action to resolve before timing out. Default is defaultCommandTimeout.
  6. waitForAnimations: Waits for the animations to finish before executing the command. Default is waitForAnimations.


1. Correct Usage

  • Clears type_here input
  • Clears textarea
  • Clear focused input/textarea

2. Wrong Usage

  • It cannot be chained off 'cy.'
  • 'get' doesn't yield input or textarea
  • 'URL' doesn't yield a DOM element.

Cypress Clear Command Example

it('Type Username And Password',()=>{
  • Here is the username field. After typing in the text, it gets cleared of it.
  • In the password field, it gets cleared before typing in the input text.

Cypress Clear Command

Submitted by arilio666 on March 29, 2022

Ashwin is working with iVagus as a Technical Lead. He has experience in various technologies like Cypress, JavaScript, TypeScript, Rest Assured, Selenium, Cucumber, and Java.


At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.