{
  "doc": {
    "id": "api/commands/clear",
    "title": "cy.clear()",
    "description": "Clear the value of an input or textarea in Cypress.",
    "section": "api",
    "source_path": "/llm/markdown/api/commands/clear.md",
    "version": "29f95bf8bb06f320986f3749f5bf09a35a409eab",
    "updated_at": "2026-09-04T10:49:54.630Z",
    "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",
        "text": "Yields",
        "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",
        "text": "Requirements",
        "level": 3
      },
      {
        "id": "api/commands/clear#assertions",
        "text": "Assertions",
        "level": 3
      },
      {
        "id": "api/commands/clear#timeouts",
        "text": "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()\n.clear(options)\n```\n\n### Usage\n\n**Correct Usage**\n\n```\ncy.get('[type=\"text\"]').clear() // Clear text input\ncy.get('textarea').type('Hi!')\ncy.get('textarea').clear() // Clear textarea\ncy.focused().clear() // Clear focused input/textarea\n```\n\n**Incorrect Usage**\n\n```\ncy.clear() // Errors, cannot be chained off 'cy'\ncy.get('nav').clear() // Errors, 'get' doesn't yield input or textarea\ncy.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. Accepts a single alignment, a per-axis `{ block, inline }` object, or `false`. |\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\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": 300
    },
    {
      "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 input\ncy.get('textarea').type('Hi!')\ncy.get('textarea').clear() // Clear textarea\ncy.focused().clear() // Clear focused input/textarea\n```\n\n**Incorrect Usage**\n\n```\ncy.clear() // Errors, cannot be chained off 'cy'\ncy.get('nav').clear() // Errors, 'get' doesn't yield input or textarea\ncy.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": 68
    },
    {
      "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. Accepts a single alignment, a per-axis `{ block, inline }` object, or `false`. |\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": 189
    },
    {
      "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\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\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\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": 108
    },
    {
      "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()\ncy.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": 52
    }
  ]
}