{
  "doc": {
    "id": "api/commands/clear",
    "title": "clear | Cypress Documentation",
    "description": "Clear the value of an input or textarea in Cypress.",
    "section": "api",
    "source_path": "/llm/markdown/api/commands/clear.md",
    "version": "48b03b5502f7aea1d0454750cce208f775403542",
    "updated_at": "2026-05-20T19:00:20.270Z",
    "headings": [
      {
        "id": "api/commands/clear#clear",
        "text": "clear",
        "level": 1
      },
      {
        "id": "api/commands/clear#syntax",
        "text": "Syntax",
        "level": 2
      },
      {
        "id": "api/commands/clear#usage",
        "text": "Usage",
        "level": 3
      },
      {
        "id": "api/commands/clear#arguments",
        "text": "Arguments",
        "level": 3
      },
      {
        "id": "api/commands/clear#yields-learn-about-subject-management",
        "text": "Yields Learn about subject management",
        "level": 3
      },
      {
        "id": "api/commands/clear#examples",
        "text": "Examples",
        "level": 2
      },
      {
        "id": "api/commands/clear#no-args",
        "text": "No Args",
        "level": 3
      },
      {
        "id": "api/commands/clear#clear-the-input-and-type-a-new-value",
        "text": "Clear the input and type a new value",
        "level": 4
      },
      {
        "id": "api/commands/clear#notes",
        "text": "Notes",
        "level": 2
      },
      {
        "id": "api/commands/clear#actionability",
        "text": "Actionability",
        "level": 3
      },
      {
        "id": "api/commands/clear#the-element-must-first-reach-actionability",
        "text": "The element must first reach actionability",
        "level": 4
      },
      {
        "id": "api/commands/clear#documentation",
        "text": "Documentation",
        "level": 3
      },
      {
        "id": "api/commands/clear#rules",
        "text": "Rules",
        "level": 2
      },
      {
        "id": "api/commands/clear#requirements-learn-about-chaining-commands",
        "text": "Requirements Learn about chaining commands",
        "level": 3
      },
      {
        "id": "api/commands/clear#assertions-learn-about-assertions",
        "text": "Assertions Learn about assertions",
        "level": 3
      },
      {
        "id": "api/commands/clear#timeouts-learn-about-timeouts",
        "text": "Timeouts Learn about timeouts",
        "level": 3
      },
      {
        "id": "api/commands/clear#command-log",
        "text": "Command Log",
        "level": 2
      },
      {
        "id": "api/commands/clear#see-also",
        "text": "See also",
        "level": 2
      }
    ]
  },
  "chunks": [
    {
      "id": "api/commands/clear#syntax",
      "doc_id": "api/commands/clear",
      "heading": "Syntax",
      "heading_level": 2,
      "content_markdown": "## Syntax\n\n```\n.clear().clear(options)\n```\n\n### Usage\n\n**Correct Usage**\n\n```\ncy.get('[type=\"text\"]').clear() // Clear text inputcy.get('textarea').type('Hi!')cy.get('textarea').clear() // Clear textareacy.focused().clear() // Clear focused input/textarea\n```\n\n**Incorrect Usage**\n\n```\ncy.clear() // Errors, cannot be chained off 'cy'cy.get('nav').clear() // Errors, 'get' doesn't yield input or textareacy.clock().clear() // Errors, 'clock' does not yield DOM elements\n```\n\n### Arguments\n\n**options _(Object)_**\n\nPass in an options object to change the default behavior of `.clear()`.\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `animationDistanceThreshold` | [`animationDistanceThreshold`](/llm/markdown/app/references/configuration.md#Actionability) | The distance in pixels an element must exceed over time to be [considered animating](/llm/markdown/app/core-concepts/interacting-with-elements.md#Animations). |\n| `force` | `false` | Forces the action, disables [waiting for actionability](#Assertions) |\n| `log` | `true` | Displays the command in the [Command log](/llm/markdown/app/core-concepts/open-mode.md#Command-Log) |\n| `scrollBehavior` | [`scrollBehavior`](/llm/markdown/app/references/configuration.md#Actionability) | Viewport position to where an element [should be scrolled](/llm/markdown/app/core-concepts/interacting-with-elements.md#Scrolling) before executing the command |\n| `timeout` | [`defaultCommandTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `.clear()` to resolve before [timing out](#Timeouts) |\n| `waitForAnimations` | [`waitForAnimations`](/llm/markdown/app/references/configuration.md#Actionability) | Whether to wait for elements to [finish animating](/llm/markdown/app/core-concepts/interacting-with-elements.md#Animations) before executing the command. |\n\n### Yields [Learn about subject management](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Subject-Management)\n\n*   `.clear()` yields the same subject it was given.\n*   It is [unsafe](/llm/markdown/app/core-concepts/retry-ability.md#Only-queries-are-retried) to chain further commands that rely on the subject after `.clear()`.\n",
      "section": "api",
      "anchors": [
        "syntax"
      ],
      "path": "/llm/json/chunked/api/commands/clear.json",
      "token_estimate": 280
    },
    {
      "id": "api/commands/clear#usage",
      "doc_id": "api/commands/clear",
      "heading": "Usage",
      "heading_level": 3,
      "content_markdown": "### Usage\n\n**Correct Usage**\n\n```\ncy.get('[type=\"text\"]').clear() // Clear text inputcy.get('textarea').type('Hi!')cy.get('textarea').clear() // Clear textareacy.focused().clear() // Clear focused input/textarea\n```\n\n**Incorrect Usage**\n\n```\ncy.clear() // Errors, cannot be chained off 'cy'cy.get('nav').clear() // Errors, 'get' doesn't yield input or textareacy.clock().clear() // Errors, 'clock' does not yield DOM elements\n```\n",
      "section": "api",
      "anchors": [
        "usage"
      ],
      "path": "/llm/json/chunked/api/commands/clear.json",
      "token_estimate": 61
    },
    {
      "id": "api/commands/clear#arguments",
      "doc_id": "api/commands/clear",
      "heading": "Arguments",
      "heading_level": 3,
      "content_markdown": "### Arguments\n\n**options _(Object)_**\n\nPass in an options object to change the default behavior of `.clear()`.\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `animationDistanceThreshold` | [`animationDistanceThreshold`](/llm/markdown/app/references/configuration.md#Actionability) | The distance in pixels an element must exceed over time to be [considered animating](/llm/markdown/app/core-concepts/interacting-with-elements.md#Animations). |\n| `force` | `false` | Forces the action, disables [waiting for actionability](#Assertions) |\n| `log` | `true` | Displays the command in the [Command log](/llm/markdown/app/core-concepts/open-mode.md#Command-Log) |\n| `scrollBehavior` | [`scrollBehavior`](/llm/markdown/app/references/configuration.md#Actionability) | Viewport position to where an element [should be scrolled](/llm/markdown/app/core-concepts/interacting-with-elements.md#Scrolling) before executing the command |\n| `timeout` | [`defaultCommandTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `.clear()` to resolve before [timing out](#Timeouts) |\n| `waitForAnimations` | [`waitForAnimations`](/llm/markdown/app/references/configuration.md#Actionability) | Whether to wait for elements to [finish animating](/llm/markdown/app/core-concepts/interacting-with-elements.md#Animations) before executing the command. |\n",
      "section": "api",
      "anchors": [
        "arguments"
      ],
      "path": "/llm/json/chunked/api/commands/clear.json",
      "token_estimate": 172
    },
    {
      "id": "api/commands/clear#yields-learn-about-subject-management",
      "doc_id": "api/commands/clear",
      "heading": "Yields Learn about subject management",
      "heading_level": 3,
      "content_markdown": "### Yields [Learn about subject management](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Subject-Management)\n\n*   `.clear()` yields the same subject it was given.\n*   It is [unsafe](/llm/markdown/app/core-concepts/retry-ability.md#Only-queries-are-retried) to chain further commands that rely on the subject after `.clear()`.\n",
      "section": "api",
      "anchors": [
        "yields-learn-about-subject-management"
      ],
      "path": "/llm/json/chunked/api/commands/clear.json",
      "token_estimate": 40
    },
    {
      "id": "api/commands/clear#notes",
      "doc_id": "api/commands/clear",
      "heading": "Notes",
      "heading_level": 2,
      "content_markdown": "## Notes\n\n### Actionability\n\n#### The element must first reach actionability\n\n`.clear()` is an \"action command\" that follows all the rules of [Actionability](/llm/markdown/app/core-concepts/interacting-with-elements.md).\n\n### Documentation\n\n`.clear()` is an alias for [`.type({selectall}{del})`](/llm/markdown/api/commands/type.md).\n\nPlease read the [`.type()`](/llm/markdown/api/commands/type.md) documentation for more details.\n",
      "section": "api",
      "anchors": [
        "notes"
      ],
      "path": "/llm/json/chunked/api/commands/clear.json",
      "token_estimate": 52
    },
    {
      "id": "api/commands/clear#rules",
      "doc_id": "api/commands/clear",
      "heading": "Rules",
      "heading_level": 2,
      "content_markdown": "## Rules\n\n### Requirements [Learn about chaining commands](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Chains-of-Commands)\n\n*   `.clear()` requires being chained off a command that yields DOM element(s).\n*   `.clear()` requires the element to be an `input` or `textarea`.\n\n### Assertions [Learn about assertions](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Assertions)\n\n*   `.clear()` will automatically wait for the element to reach an [actionable state](/llm/markdown/app/core-concepts/interacting-with-elements.md)\n*   `.clear()` will automatically [retry](/llm/markdown/app/core-concepts/retry-ability.md) until all chained assertions have passed\n\n### Timeouts [Learn about timeouts](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Timeouts)\n\n*   `.clear()` can time out waiting for the element to reach an [actionable state](/llm/markdown/app/core-concepts/interacting-with-elements.md).\n*   `.clear()` can time out waiting for assertions you've added to pass.\n",
      "section": "api",
      "anchors": [
        "rules"
      ],
      "path": "/llm/json/chunked/api/commands/clear.json",
      "token_estimate": 121
    },
    {
      "id": "api/commands/clear#timeouts-learn-about-timeouts",
      "doc_id": "api/commands/clear",
      "heading": "Timeouts Learn about timeouts",
      "heading_level": 3,
      "content_markdown": "### Timeouts [Learn about timeouts](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Timeouts)\n\n*   `.clear()` can time out waiting for the element to reach an [actionable state](/llm/markdown/app/core-concepts/interacting-with-elements.md).\n*   `.clear()` can time out waiting for assertions you've added to pass.\n",
      "section": "api",
      "anchors": [
        "timeouts-learn-about-timeouts"
      ],
      "path": "/llm/json/chunked/api/commands/clear.json",
      "token_estimate": 41
    },
    {
      "id": "api/commands/clear#command-log",
      "doc_id": "api/commands/clear",
      "heading": "Command Log",
      "heading_level": 2,
      "content_markdown": "## Command Log\n\n**_Clear the input and type a new value_**\n\n```\ncy.get('input[name=\"name\"]').clear()cy.get('input[name=\"name\"]').type('Jane Lane')\n```\n\nThe commands above will display in the Command Log as:\n\nWhen clicking on `clear` within the command log, the console outputs the following:\n",
      "section": "api",
      "anchors": [
        "command-log"
      ],
      "path": "/llm/json/chunked/api/commands/clear.json",
      "token_estimate": 51
    }
  ]
}