{
  "doc": {
    "id": "api/commands/not",
    "title": "cy.not()",
    "description": "Filter DOM element(s) from a set of DOM elements in Cypress.",
    "section": "api",
    "source_path": "/llm/markdown/api/commands/not.md",
    "version": "e6c8d867c21227247f14714fb5690c7c018983c5",
    "updated_at": "2026-08-08T12:39:37.868Z",
    "headings": [
      {
        "id": "api/commands/not#not",
        "text": "not",
        "level": 1
      },
      {
        "id": "api/commands/not#syntax",
        "text": "Syntax",
        "level": 2
      },
      {
        "id": "api/commands/not#usage",
        "text": "Usage",
        "level": 3
      },
      {
        "id": "api/commands/not#arguments",
        "text": "Arguments",
        "level": 3
      },
      {
        "id": "api/commands/not#yields",
        "text": "Yields",
        "level": 3
      },
      {
        "id": "api/commands/not#examples",
        "text": "Examples",
        "level": 2
      },
      {
        "id": "api/commands/not#selector",
        "text": "Selector",
        "level": 3
      },
      {
        "id": "api/commands/not#yield-the-elements-that-do-not-have-class-active",
        "text": "Yield the elements that do not have class active",
        "level": 4
      },
      {
        "id": "api/commands/not#contains",
        "text": "Contains",
        "level": 3
      },
      {
        "id": "api/commands/not#yield-the-elements-that-do-not-contain-some-text",
        "text": "Yield the elements that do not contain some text",
        "level": 4
      },
      {
        "id": "api/commands/not#rules",
        "text": "Rules",
        "level": 2
      },
      {
        "id": "api/commands/not#requirements",
        "text": "Requirements",
        "level": 3
      },
      {
        "id": "api/commands/not#assertions",
        "text": "Assertions",
        "level": 3
      },
      {
        "id": "api/commands/not#timeouts",
        "text": "Timeouts",
        "level": 3
      },
      {
        "id": "api/commands/not#command-log",
        "text": "Command Log",
        "level": 2
      },
      {
        "id": "api/commands/not#see-also",
        "text": "See also",
        "level": 2
      }
    ]
  },
  "chunks": [
    {
      "id": "api/commands/not#syntax",
      "doc_id": "api/commands/not",
      "heading": "Syntax",
      "heading_level": 2,
      "content_markdown": "## Syntax\n\n```\n.not(selector).not(selector, options)\n```\n\n### Usage\n\n**Correct Usage**\n\n```\ncy.get('input').not('.required') // Yield all inputs without class '.required'\n```\n\n**Incorrect Usage**\n\n```\ncy.not('.icon') // Errors, cannot be chained off 'cy'cy.clock().not() // Errors, 'clock' does not yield DOM elements\n```\n\n### Arguments\n\n**selector _(String selector)_**\n\nA selector used to remove matching DOM elements.\n\n**options _(Object)_**\n\nPass in an options object to change the default behavior of `.not()`.\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `log` | `true` | Displays the command in the [Command log](/llm/markdown/app/core-concepts/open-mode.md#Command-Log) |\n| `timeout` | [`defaultCommandTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `.not()` to resolve before [timing out](#Timeouts) |\n\n### Yields\n\n*   `.not()` yields the new DOM element(s) it found.\n*   `.not()` is a query, and it is _safe_ to chain further commands.\n",
      "section": "api",
      "anchors": [
        "syntax"
      ],
      "path": "/llm/json/chunked/api/commands/not.json",
      "token_estimate": 179
    },
    {
      "id": "api/commands/not#usage",
      "doc_id": "api/commands/not",
      "heading": "Usage",
      "heading_level": 3,
      "content_markdown": "### Usage\n\n**Correct Usage**\n\n```\ncy.get('input').not('.required') // Yield all inputs without class '.required'\n```\n\n**Incorrect Usage**\n\n```\ncy.not('.icon') // Errors, cannot be chained off 'cy'cy.clock().not() // Errors, 'clock' does not yield DOM elements\n```\n",
      "section": "api",
      "anchors": [
        "usage"
      ],
      "path": "/llm/json/chunked/api/commands/not.json",
      "token_estimate": 45
    },
    {
      "id": "api/commands/not#arguments",
      "doc_id": "api/commands/not",
      "heading": "Arguments",
      "heading_level": 3,
      "content_markdown": "### Arguments\n\n**selector _(String selector)_**\n\nA selector used to remove matching DOM elements.\n\n**options _(Object)_**\n\nPass in an options object to change the default behavior of `.not()`.\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `log` | `true` | Displays the command in the [Command log](/llm/markdown/app/core-concepts/open-mode.md#Command-Log) |\n| `timeout` | [`defaultCommandTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `.not()` to resolve before [timing out](#Timeouts) |\n",
      "section": "api",
      "anchors": [
        "arguments"
      ],
      "path": "/llm/json/chunked/api/commands/not.json",
      "token_estimate": 93
    },
    {
      "id": "api/commands/not#examples",
      "doc_id": "api/commands/not",
      "heading": "Examples",
      "heading_level": 2,
      "content_markdown": "## Examples\n\n### Selector\n\n#### Yield the elements that do not have class `active`\n\n```\n<ul>  <li>Home</li>  <li class=\"active\">About</li>  <li>Services</li>  <li>Pricing</li>  <li>Contact</li></ul>\n```\n\n```\ncy.get('ul>li').not('.active').should('have.length', 4) // true\n```\n\n### Contains\n\n#### Yield the elements that do not contain some text\n\nThere is no built-in negation for [`cy.contains()`](/llm/markdown/api/commands/contains.md), so there is no way to ask it directly for the elements that do _not_ contain a piece of text. Instead, select the full set of elements and remove the matching ones with [`.not()`](/llm/markdown/api/commands/not.md) and the [jQuery :contains](https://api.jquery.com/contains-selector/) selector. The match is a case-sensitive substring match.\n\n```\n<ul>  <li>Test: Name</li>  <li>Test: Name (1)</li>  <li>Test: Name (2)</li>  <li>Test: Name (3)</li></ul>\n```\n\n```\n// yields only <li>Test: Name</li>, the item without a numeric suffixcy.get('li').not(':contains(\"(\")')\n```\n\nThe same approach works with [`.filter()`](/llm/markdown/api/commands/filter.md) and the [:not()](https://api.jquery.com/not-selector/) selector when you would rather keep a positive filter:\n\n```\n// yields the rows that are not disabledcy.get('tr').filter(':not(.disabled)')\n```\n",
      "section": "api",
      "anchors": [
        "examples"
      ],
      "path": "/llm/json/chunked/api/commands/not.json",
      "token_estimate": 199
    },
    {
      "id": "api/commands/not#contains",
      "doc_id": "api/commands/not",
      "heading": "Contains",
      "heading_level": 3,
      "content_markdown": "### Contains\n\n#### Yield the elements that do not contain some text\n\nThere is no built-in negation for [`cy.contains()`](/llm/markdown/api/commands/contains.md), so there is no way to ask it directly for the elements that do _not_ contain a piece of text. Instead, select the full set of elements and remove the matching ones with [`.not()`](/llm/markdown/api/commands/not.md) and the [jQuery :contains](https://api.jquery.com/contains-selector/) selector. The match is a case-sensitive substring match.\n\n```\n<ul>  <li>Test: Name</li>  <li>Test: Name (1)</li>  <li>Test: Name (2)</li>  <li>Test: Name (3)</li></ul>\n```\n\n```\n// yields only <li>Test: Name</li>, the item without a numeric suffixcy.get('li').not(':contains(\"(\")')\n```\n\nThe same approach works with [`.filter()`](/llm/markdown/api/commands/filter.md) and the [:not()](https://api.jquery.com/not-selector/) selector when you would rather keep a positive filter:\n\n```\n// yields the rows that are not disabledcy.get('tr').filter(':not(.disabled)')\n```\n",
      "section": "api",
      "anchors": [
        "contains"
      ],
      "path": "/llm/json/chunked/api/commands/not.json",
      "token_estimate": 160
    },
    {
      "id": "api/commands/not#yield-the-elements-that-do-not-contain-some-text",
      "doc_id": "api/commands/not",
      "heading": "Yield the elements that do not contain some text",
      "heading_level": 4,
      "content_markdown": "#### Yield the elements that do not contain some text\n\nThere is no built-in negation for [`cy.contains()`](/llm/markdown/api/commands/contains.md), so there is no way to ask it directly for the elements that do _not_ contain a piece of text. Instead, select the full set of elements and remove the matching ones with [`.not()`](/llm/markdown/api/commands/not.md) and the [jQuery :contains](https://api.jquery.com/contains-selector/) selector. The match is a case-sensitive substring match.\n\n```\n<ul>  <li>Test: Name</li>  <li>Test: Name (1)</li>  <li>Test: Name (2)</li>  <li>Test: Name (3)</li></ul>\n```\n\n```\n// yields only <li>Test: Name</li>, the item without a numeric suffixcy.get('li').not(':contains(\"(\")')\n```\n\nThe same approach works with [`.filter()`](/llm/markdown/api/commands/filter.md) and the [:not()](https://api.jquery.com/not-selector/) selector when you would rather keep a positive filter:\n\n```\n// yields the rows that are not disabledcy.get('tr').filter(':not(.disabled)')\n```\n",
      "section": "api",
      "anchors": [
        "yield-the-elements-that-do-not-contain-some-text"
      ],
      "path": "/llm/json/chunked/api/commands/not.json",
      "token_estimate": 157
    },
    {
      "id": "api/commands/not#rules",
      "doc_id": "api/commands/not",
      "heading": "Rules",
      "heading_level": 2,
      "content_markdown": "## Rules\n\n### Requirements\n\n*   `.not()` requires being chained off a command that yields DOM element(s).\n\n### Assertions\n\n*   `.not()` will automatically [retry](/llm/markdown/app/core-concepts/retry-ability.md) until the element(s) [exist in the DOM](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Implicit-Assertions).\n*   `.not()` will automatically [retry](/llm/markdown/app/core-concepts/retry-ability.md) until all chained assertions have passed.\n\n### Timeouts\n\n*   `.not()` can time out waiting for the element(s) to [exist in the DOM](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Implicit-Assertions).\n*   `.not()` can time out waiting for assertions you've added to pass.\n",
      "section": "api",
      "anchors": [
        "rules"
      ],
      "path": "/llm/json/chunked/api/commands/not.json",
      "token_estimate": 92
    },
    {
      "id": "api/commands/not#command-log",
      "doc_id": "api/commands/not",
      "heading": "Command Log",
      "heading_level": 2,
      "content_markdown": "## Command Log\n\n**_Find all buttons that are not of type submit_**\n\n```\ncy.get('form').find('button').not('[type=\"submit\"]')\n```\n\nThe commands above will display in the Command Log as:\n\nWhen clicking on `not` within the command log, the console outputs the following:\n",
      "section": "api",
      "anchors": [
        "command-log"
      ],
      "path": "/llm/json/chunked/api/commands/not.json",
      "token_estimate": 51
    }
  ]
}