{
  "doc": {
    "id": "api/commands/its",
    "title": "cy.its()",
    "description": "Get a property's value on the previously yielded subject in Cypress.",
    "section": "api",
    "source_path": "/llm/markdown/api/commands/its.md",
    "version": "29f95bf8bb06f320986f3749f5bf09a35a409eab",
    "updated_at": "2026-09-04T10:49:54.630Z",
    "headings": [
      {
        "id": "api/commands/its#its",
        "text": "its",
        "level": 1
      },
      {
        "id": "api/commands/its#syntax",
        "text": "Syntax",
        "level": 2
      },
      {
        "id": "api/commands/its#usage",
        "text": "Usage",
        "level": 3
      },
      {
        "id": "api/commands/its#arguments",
        "text": "Arguments",
        "level": 3
      },
      {
        "id": "api/commands/its#yields",
        "text": "Yields",
        "level": 3
      },
      {
        "id": "api/commands/its#examples",
        "text": "Examples",
        "level": 2
      },
      {
        "id": "api/commands/its#objects",
        "text": "Objects",
        "level": 3
      },
      {
        "id": "api/commands/its#get-property",
        "text": "Get property",
        "level": 4
      },
      {
        "id": "api/commands/its#arrays",
        "text": "Arrays",
        "level": 3
      },
      {
        "id": "api/commands/its#get-index",
        "text": "Get index",
        "level": 4
      },
      {
        "id": "api/commands/its#dom-elements",
        "text": "DOM Elements",
        "level": 3
      },
      {
        "id": "api/commands/its#get-the-length-property-of-a-dom-element",
        "text": "Get the length property of a DOM element",
        "level": 4
      },
      {
        "id": "api/commands/its#requests",
        "text": "Requests",
        "level": 3
      },
      {
        "id": "api/commands/its#get-the-user-object-of-the-responses-body",
        "text": "Get the user object of the response's body",
        "level": 4
      },
      {
        "id": "api/commands/its#strings",
        "text": "Strings",
        "level": 3
      },
      {
        "id": "api/commands/its#get-length-of-title",
        "text": "Get length of title",
        "level": 4
      },
      {
        "id": "api/commands/its#functions",
        "text": "Functions",
        "level": 3
      },
      {
        "id": "api/commands/its#get-function-as-property",
        "text": "Get function as property",
        "level": 4
      },
      {
        "id": "api/commands/its#access-function-properties",
        "text": "Access function properties",
        "level": 4
      },
      {
        "id": "api/commands/its#use-its-to-test-window-fetch",
        "text": "Use .its() to test window.fetch",
        "level": 4
      },
      {
        "id": "api/commands/its#nested-properties",
        "text": "Nested Properties",
        "level": 3
      },
      {
        "id": "api/commands/its#existence",
        "text": "Existence",
        "level": 3
      },
      {
        "id": "api/commands/its#wait-for-some-property-to-exist-on-window",
        "text": "Wait for some property to exist on window",
        "level": 4
      },
      {
        "id": "api/commands/its#assert-that-a-property-does-not-exist-on-window",
        "text": "Assert that a property does not exist on window",
        "level": 4
      },
      {
        "id": "api/commands/its#rules",
        "text": "Rules",
        "level": 2
      },
      {
        "id": "api/commands/its#requirements",
        "text": "Requirements",
        "level": 3
      },
      {
        "id": "api/commands/its#assertions",
        "text": "Assertions",
        "level": 3
      },
      {
        "id": "api/commands/its#timeouts",
        "text": "Timeouts",
        "level": 3
      },
      {
        "id": "api/commands/its#command-log",
        "text": "Command Log",
        "level": 2
      },
      {
        "id": "api/commands/its#history",
        "text": "History",
        "level": 2
      },
      {
        "id": "api/commands/its#see-also",
        "text": "See also",
        "level": 2
      }
    ]
  },
  "content": {
    "type": "root",
    "children": [
      {
        "type": "heading",
        "depth": 1,
        "children": [
          {
            "type": "text",
            "value": "its"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Get a property's value on the previously yielded subject."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "If you want to call a `function` on the previously yielded subject, use "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/api/commands/invoke.md",
            "children": [
              {
                "type": "text",
                "value": "`.invoke()`"
              }
            ]
          },
          {
            "type": "text",
            "value": "."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Syntax"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": ".its(propertyName)\n.its(propertyName, options)"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Usage"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Correct Usage"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.wrap({ width: '50' }).its('width') // Get the 'width' property\ncy.window().its('sessionStorage') // Get the 'sessionStorage' property"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Incorrect Usage"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.its('window') // Errors, cannot be chained off 'cy'\ncy.clearCookies().its('length') // Errors, 'clearCookies' does not yield Object"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Arguments"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "propertyName (String, Number)"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Index, name of property or name of nested properties (with dot notation) to get."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "options (Object)"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Pass in an options object to change the default behavior of `.its()`."
          }
        ]
      },
      {
        "type": "table",
        "align": [
          null,
          null,
          null
        ],
        "children": [
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Option"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Default"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Description"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "`log`"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "`true`"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Displays the command in the "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/core-concepts/open-mode.md#Command-Log",
                    "children": [
                      {
                        "type": "text",
                        "value": "Command log"
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "`timeout`"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/references/configuration.md#Timeouts",
                    "children": [
                      {
                        "type": "text",
                        "value": "`defaultCommandTimeout`"
                      }
                    ]
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Time to wait for `.its()` to resolve before "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "#Timeouts",
                    "children": [
                      {
                        "type": "text",
                        "value": "timing out"
                      }
                    ]
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Yields"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "`.its()` 'yields the value of the property."
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "`.its()` is a query, and it is safe to chain further commands."
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Examples"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Objects"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Get property"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.wrap({ age: 52 }).its('age').should('eq', 52) // true"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Arrays"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Get index"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.wrap(['Wai Yan', 'Yu']).its(1).should('eq', 'Yu') // true"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "DOM Elements"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Get the `length` property of a DOM element"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.get('ul li') // this yields us a jquery object\n  .its('length') // calls 'length' property returning that value\n  .should('be.gt', 2) // ensure the length is greater than 2"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Requests"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Get the `user` object of the response's `body`"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy\n  .request(...)\n  .its('body.user')\n  .then(user => ...)"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "alternatively, use destructuring"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy\n  .request(...)\n  .its('body')\n  .then(({user}) => ...)"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Strings"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Get `length` of title"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.title().its('length').should('eq', 24)"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Functions"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Get function as property"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "const fn = () => {\n  return 42\n}\n\ncy.wrap({ getNum: fn }).its('getNum').should('be.a', 'function')"
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Access function properties"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "You can access functions to then drill into their own properties instead of invoking them."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// Your app code\n// a basic Factory constructor\nconst Factory = (arg) => {\n  // ...\n}\n\nFactory.create = (arg) => {\n  return new Factory(arg)\n}\n\n// assign it to the window\nwindow.Factory = Factory"
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.window() // yields window object\n  .its('Factory') // yields Factory function\n  .invoke('create', 'arg') // now invoke properties on it"
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Use `.its()` to test `window.fetch`"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/references/recipes.md#Stubbing-and-spying",
            "children": [
              {
                "type": "text",
                "value": "Check out our example recipe on testing `window.fetch` using `.its()`"
              }
            ]
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Nested Properties"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "You can drill into nested properties by using dot notation."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "const user = {\n  contacts: {\n    work: {\n      name: 'Kamil',\n    },\n  },\n}\n\ncy.wrap(user).its('contacts.work.name').should('eq', 'Kamil') // true"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Existence"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Wait for some property to exist on `window`"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.window()\n  .its('globalProp')\n  .then((globalProp) => {\n    // do something now that window.globalProp exists\n  })"
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Assert that a property does not exist on `window`"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.window().its('evilProp').should('not.exist')"
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Rules"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Requirements"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "`.its()` requires being chained off a previous command."
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Assertions"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "`.its()` will automatically "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/core-concepts/retry-ability.md",
                    "children": [
                      {
                        "type": "text",
                        "value": "retry"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": " until it has a property that is not `null` or `undefined`."
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Timeouts"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "`.its()` can time out waiting for the property to exist."
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "`.its()` can time out waiting for assertions you've added to pass."
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Command Log"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Get `responseBody` of aliased route"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.intercept('/comments', { fixture: 'comments.json' }).as('getComments')\ncy.get('#fetch-comments').click()\ncy.wait('@getComments')\n  .its('response.body')\n  .should(\n    'deep.eq',\n    JSON.stringify([\n      { id: 1, comment: 'hi' },\n      { id: 2, comment: 'there' },\n    ])\n  )"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "The commands above will display in the Command Log as:"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "When clicking on `its` within the command log, the console outputs the following:"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "History"
          }
        ]
      },
      {
        "type": "table",
        "align": [
          null,
          null
        ],
        "children": [
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Version"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Changes"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/references/changelog.md#3-8-0",
                    "children": [
                      {
                        "type": "text",
                        "value": "3.8.0"
                      }
                    ]
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Added support for `options` argument"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/references/changelog.md#3-7-0",
                    "children": [
                      {
                        "type": "text",
                        "value": "3.7.0"
                      }
                    ]
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Added support for arguments of type Number for `propertyName`"
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "See also"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/api/commands/invoke.md",
                    "children": [
                      {
                        "type": "text",
                        "value": "`.invoke()`"
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/api/commands/then.md",
                    "children": [
                      {
                        "type": "text",
                        "value": "`.then()`"
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/api/commands/wrap.md",
                    "children": [
                      {
                        "type": "text",
                        "value": "`cy.wrap()`"
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "https://github.com/bahmutov/test-todomvc-using-app-actions#intellisense",
                    "children": [
                      {
                        "type": "text",
                        "value": "Adding custom properties to the global `window` with the right TypeScript type"
                      }
                    ]
                  }
                ]
              }
            ]
          }
        ]
      }
    ]
  },
  "token_estimate": 853
}