{
  "doc": {
    "id": "api/commands/children",
    "title": "children | Cypress Documentation",
    "description": "Get the children of each DOM element within a set of DOM elements in Cypress.",
    "section": "api",
    "source_path": "/llm/markdown/api/commands/children.md",
    "version": "e6988a974973e9090ce70406c38cb2b9e0eac9fa",
    "updated_at": "2026-05-15T15:50:22.536Z",
    "headings": [
      {
        "id": "api/commands/children#children",
        "text": "children",
        "level": 1
      },
      {
        "id": "api/commands/children#syntax",
        "text": "Syntax",
        "level": 2
      },
      {
        "id": "api/commands/children#usage",
        "text": "Usage",
        "level": 3
      },
      {
        "id": "api/commands/children#arguments",
        "text": "Arguments",
        "level": 3
      },
      {
        "id": "api/commands/children#yields-learn-about-subject-management",
        "text": "Yields Learn about subject management",
        "level": 3
      },
      {
        "id": "api/commands/children#examples",
        "text": "Examples",
        "level": 2
      },
      {
        "id": "api/commands/children#no-args",
        "text": "No Args",
        "level": 3
      },
      {
        "id": "api/commands/children#get-the-children-of-the-secondary-nav",
        "text": "Get the children of the .secondary-nav",
        "level": 4
      },
      {
        "id": "api/commands/children#selector",
        "text": "Selector",
        "level": 3
      },
      {
        "id": "api/commands/children#get-the-children-with-class-active",
        "text": "Get the children with class active",
        "level": 4
      },
      {
        "id": "api/commands/children#rules",
        "text": "Rules",
        "level": 2
      },
      {
        "id": "api/commands/children#requirements-learn-about-chaining-commands",
        "text": "Requirements Learn about chaining commands",
        "level": 3
      },
      {
        "id": "api/commands/children#assertions-learn-about-assertions",
        "text": "Assertions Learn about assertions",
        "level": 3
      },
      {
        "id": "api/commands/children#timeouts-learn-about-timeouts",
        "text": "Timeouts Learn about timeouts",
        "level": 3
      },
      {
        "id": "api/commands/children#command-log",
        "text": "Command Log",
        "level": 2
      },
      {
        "id": "api/commands/children#see-also",
        "text": "See also",
        "level": 2
      }
    ]
  },
  "chunks": [
    {
      "id": "api/commands/children#syntax",
      "doc_id": "api/commands/children",
      "heading": "Syntax",
      "heading_level": 2,
      "content_markdown": "## Syntax\n\n```\n.children().children(selector).children(options).children(selector, options)\n```\n\n### Usage\n\n**Correct Usage**\n\n```\ncy.get('nav').children() // Yield children of nav\n```\n\n**Incorrect Usage**\n\n```\ncy.children() // Errors, cannot be chained off 'cy'cy.clock().children() // Errors, 'clock' does not yield DOM elements\n```\n\n### Arguments\n\n**selector _(String selector)_**\n\nA selector used to filter matching DOM elements.\n\n**options _(Object)_**\n\nPass in an options object to change the default behavior of `.children()`.\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 `.children()` to resolve before [timing out](#Timeouts) |\n\n### Yields [Learn about subject management](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Subject-Management)\n\n*   `.children()` yields the new DOM element(s) it found.\n*   `.children()` is a query, and it is _safe_ to chain further commands.\n",
      "section": "api",
      "anchors": [
        "syntax"
      ],
      "path": "/llm/json/chunked/api/commands/children.json",
      "token_estimate": 181
    },
    {
      "id": "api/commands/children#usage",
      "doc_id": "api/commands/children",
      "heading": "Usage",
      "heading_level": 3,
      "content_markdown": "### Usage\n\n**Correct Usage**\n\n```\ncy.get('nav').children() // Yield children of nav\n```\n\n**Incorrect Usage**\n\n```\ncy.children() // Errors, cannot be chained off 'cy'cy.clock().children() // Errors, 'clock' does not yield DOM elements\n```\n",
      "section": "api",
      "anchors": [
        "usage"
      ],
      "path": "/llm/json/chunked/api/commands/children.json",
      "token_estimate": 43
    },
    {
      "id": "api/commands/children#arguments",
      "doc_id": "api/commands/children",
      "heading": "Arguments",
      "heading_level": 3,
      "content_markdown": "### Arguments\n\n**selector _(String selector)_**\n\nA selector used to filter matching DOM elements.\n\n**options _(Object)_**\n\nPass in an options object to change the default behavior of `.children()`.\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 `.children()` to resolve before [timing out](#Timeouts) |\n",
      "section": "api",
      "anchors": [
        "arguments"
      ],
      "path": "/llm/json/chunked/api/commands/children.json",
      "token_estimate": 93
    },
    {
      "id": "api/commands/children#examples",
      "doc_id": "api/commands/children",
      "heading": "Examples",
      "heading_level": 2,
      "content_markdown": "## Examples\n\n### No Args\n\n#### Get the children of the `.secondary-nav`\n\n```\n<ul>  <li>About</li>  <li>    Services    <ul class=\"secondary-nav\">      <li class=\"services-1\">Web Design</li>      <li class=\"services-2\">Logo Design</li>      <li class=\"services-3\">        Print Design        <ul class=\"tertiary-nav\">          <li>Signage</li>          <li>T-Shirt</li>          <li>Business Cards</li>        </ul>      </li>    </ul>  </li>  <li>Contact</li></ul>\n```\n\n```\n// yields [//  <li class=\"services-1\">Web Design</li>,//  <li class=\"services-2\">Logo Design</li>,//  <li class=\"services-3\">Print Design</li>// ]cy.get('ul.secondary-nav').children()\n```\n\n### Selector\n\n#### Get the children with class `active`\n\n```\n<div>  <ul>    <li class=\"active\">Unit Testing</li>    <li>Integration Testing</li>  </ul></div>\n```\n\n```\n// yields [//  <li class=\"active\">Unit Testing</li>// ]cy.get('ul').children('.active')\n```\n",
      "section": "api",
      "anchors": [
        "examples"
      ],
      "path": "/llm/json/chunked/api/commands/children.json",
      "token_estimate": 112
    },
    {
      "id": "api/commands/children#no-args",
      "doc_id": "api/commands/children",
      "heading": "No Args",
      "heading_level": 3,
      "content_markdown": "### No Args\n\n#### Get the children of the `.secondary-nav`\n\n```\n<ul>  <li>About</li>  <li>    Services    <ul class=\"secondary-nav\">      <li class=\"services-1\">Web Design</li>      <li class=\"services-2\">Logo Design</li>      <li class=\"services-3\">        Print Design        <ul class=\"tertiary-nav\">          <li>Signage</li>          <li>T-Shirt</li>          <li>Business Cards</li>        </ul>      </li>    </ul>  </li>  <li>Contact</li></ul>\n```\n\n```\n// yields [//  <li class=\"services-1\">Web Design</li>,//  <li class=\"services-2\">Logo Design</li>,//  <li class=\"services-3\">Print Design</li>// ]cy.get('ul.secondary-nav').children()\n```\n",
      "section": "api",
      "anchors": [
        "no-args"
      ],
      "path": "/llm/json/chunked/api/commands/children.json",
      "token_estimate": 72
    },
    {
      "id": "api/commands/children#get-the-children-of-the-secondary-nav",
      "doc_id": "api/commands/children",
      "heading": "Get the children of the .secondary-nav",
      "heading_level": 4,
      "content_markdown": "#### Get the children of the `.secondary-nav`\n\n```\n<ul>  <li>About</li>  <li>    Services    <ul class=\"secondary-nav\">      <li class=\"services-1\">Web Design</li>      <li class=\"services-2\">Logo Design</li>      <li class=\"services-3\">        Print Design        <ul class=\"tertiary-nav\">          <li>Signage</li>          <li>T-Shirt</li>          <li>Business Cards</li>        </ul>      </li>    </ul>  </li>  <li>Contact</li></ul>\n```\n\n```\n// yields [//  <li class=\"services-1\">Web Design</li>,//  <li class=\"services-2\">Logo Design</li>,//  <li class=\"services-3\">Print Design</li>// ]cy.get('ul.secondary-nav').children()\n```\n",
      "section": "api",
      "anchors": [
        "get-the-children-of-the-secondary-nav"
      ],
      "path": "/llm/json/chunked/api/commands/children.json",
      "token_estimate": 68
    },
    {
      "id": "api/commands/children#rules",
      "doc_id": "api/commands/children",
      "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*   `.children()` requires being chained off a command that yields DOM element(s).\n\n### Assertions [Learn about assertions](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Assertions)\n\n*   `.children()` 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*   `.children()` 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*   `.children()` 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*   `.children()` can time out waiting for assertions you've added to pass.\n",
      "section": "api",
      "anchors": [
        "rules"
      ],
      "path": "/llm/json/chunked/api/commands/children.json",
      "token_estimate": 105
    },
    {
      "id": "api/commands/children#timeouts-learn-about-timeouts",
      "doc_id": "api/commands/children",
      "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*   `.children()` 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*   `.children()` 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/children.json",
      "token_estimate": 41
    },
    {
      "id": "api/commands/children#command-log",
      "doc_id": "api/commands/children",
      "heading": "Command Log",
      "heading_level": 2,
      "content_markdown": "## Command Log\n\n**_Assert that there should be 8 children elements in a nav_**\n\n```\ncy.get('.left-nav>.nav').children().should('have.length', 8)\n```\n\nThe commands above will display in the Command Log as:\n\nWhen clicking on the `children` command within the command log, the console outputs the following:\n",
      "section": "api",
      "anchors": [
        "command-log"
      ],
      "path": "/llm/json/chunked/api/commands/children.json",
      "token_estimate": 57
    }
  ]
}