{
  "doc": {
    "id": "ui-coverage/configuration/attributefilters",
    "title": "Attribute Filters | Cypress UI Coverage",
    "description": "The `attributeFilters` configuration property allows users to specify patterns for attributes and their values that should not be used for identifying and grouping elements.",
    "section": "ui-coverage",
    "source_path": "/llm/markdown/ui-coverage/configuration/attributefilters.md",
    "version": "24a73f8a97175663aaffd3b016289fb2a523a4ea",
    "updated_at": "2026-05-14T20:17:33.301Z",
    "headings": [
      {
        "id": "ui-coverage/configuration/attributefilters#attributefilters",
        "text": "attributeFilters",
        "level": 1
      },
      {
        "id": "ui-coverage/configuration/attributefilters#why-use-attribute-filters",
        "text": "Why use attribute filters?",
        "level": 2
      },
      {
        "id": "ui-coverage/configuration/attributefilters#scope",
        "text": "Scope",
        "level": 2
      },
      {
        "id": "ui-coverage/configuration/attributefilters#syntax",
        "text": "Syntax",
        "level": 2
      },
      {
        "id": "ui-coverage/configuration/attributefilters#options",
        "text": "Options",
        "level": 3
      },
      {
        "id": "ui-coverage/configuration/attributefilters#examples",
        "text": "Examples",
        "level": 2
      },
      {
        "id": "ui-coverage/configuration/attributefilters#excluding-common-auto-generated-id-values",
        "text": "Excluding common auto-generated ID values",
        "level": 3
      },
      {
        "id": "ui-coverage/configuration/attributefilters#html",
        "text": "HTML",
        "level": 4
      },
      {
        "id": "ui-coverage/configuration/attributefilters#element-identifiers-displayed",
        "text": "Element identifiers displayed",
        "level": 4
      },
      {
        "id": "ui-coverage/configuration/attributefilters#filtering-related-dynamic-attributes",
        "text": "Filtering related dynamic attributes",
        "level": 3
      },
      {
        "id": "ui-coverage/configuration/attributefilters#html",
        "text": "HTML",
        "level": 4
      },
      {
        "id": "ui-coverage/configuration/attributefilters#element-identifiers-displayed",
        "text": "Element identifiers displayed",
        "level": 4
      },
      {
        "id": "ui-coverage/configuration/attributefilters#excluding-auto-generated-attribute-names",
        "text": "Excluding auto-generated attribute names",
        "level": 3
      },
      {
        "id": "ui-coverage/configuration/attributefilters#html",
        "text": "HTML",
        "level": 4
      },
      {
        "id": "ui-coverage/configuration/attributefilters#element-identifiers-displayed",
        "text": "Element identifiers displayed",
        "level": 4
      },
      {
        "id": "ui-coverage/configuration/attributefilters#ignoring-dynamic-attributes-for-accurate-grouping",
        "text": "Ignoring dynamic attributes for accurate grouping",
        "level": 3
      },
      {
        "id": "ui-coverage/configuration/attributefilters#html",
        "text": "HTML",
        "level": 4
      },
      {
        "id": "ui-coverage/configuration/attributefilters#element-identifiers-displayed",
        "text": "Element identifiers displayed",
        "level": 4
      }
    ]
  },
  "chunks": [
    {
      "id": "ui-coverage/configuration/attributefilters#why-use-attribute-filters",
      "doc_id": "ui-coverage/configuration/attributefilters",
      "heading": "Why use attribute filters?",
      "heading_level": 2,
      "content_markdown": "## Why use attribute filters?\n\n*   **Handling library-specific attributes**: Attributes generated by libraries may not represent the element's purpose and should be ignored.\n*   **Improving grouping accuracy**: By filtering out irrelevant attributes, you ensure similar elements are grouped correctly.\n*   **Avoiding state-based duplication**: Classes like `link--focused` can clutter report findings.\n",
      "section": "ui-coverage",
      "anchors": [
        "why-use-attribute-filters"
      ],
      "path": "/llm/json/chunked/ui-coverage/configuration/attributefilters.json",
      "token_estimate": 67
    },
    {
      "id": "ui-coverage/configuration/attributefilters#scope",
      "doc_id": "ui-coverage/configuration/attributefilters",
      "heading": "Scope",
      "heading_level": 2,
      "content_markdown": "## Scope\n\n**Note:** setting `attributeFilters` impacts both Cypress Accessibility and UI Coverage reports if set at the root of the configuration. Nesting this property under an `accessibility` or `uiCoverage` key is supported, if you need to split them up.\n",
      "section": "ui-coverage",
      "anchors": [
        "scope"
      ],
      "path": "/llm/json/chunked/ui-coverage/configuration/attributefilters.json",
      "token_estimate": 52
    },
    {
      "id": "ui-coverage/configuration/attributefilters#syntax",
      "doc_id": "ui-coverage/configuration/attributefilters",
      "heading": "Syntax",
      "heading_level": 2,
      "content_markdown": "## Syntax\n\n```\n{  \"attributeFilters\": [    {      \"attribute\": string,      \"value\": string,      \"include\": boolean,      \"comment\": string    }  ]}\n```\n\n### Options\n\nWhether Cypress is allowed to use a certain attribute to identify an element when processing it for UI Coverage or Cypress Accessibility reports will be controlled by the **first** filter that matches the name and value of that attribute.\n\nThis means that catch-all rules can be added at the bottom of the list by setting `include` to `false`, and exceptions can be defined earlier in the list using `include: true`. For example, you could avoid all use of `aria-label` for identification of elements as a catch-call filter, but then define exceptions for certain values it may have where it is a good identifier.\n\nAttributes that do not match any rules are included by default and used if needed, so `include: true` is only required for defining exceptions. If you want to make sure an attribute is preferred as an identifier when available, add it to your [attributeFilters](/llm/markdown/accessibility/configuration/attributefilters.md).\n\n| Option | Required | Default | Description |\n| --- | --- | --- | --- |\n| `attribute` | Required |  | A regex string to match attribute names |\n| `value` | Optional | `.*` | A regex string to match attribute values |\n| `include` | Optional | `true` | A boolean to specify whether the matched attribute should be included. |\n| `comment` | Optional |  | A comment describing the purpose of this filter rule. |\n",
      "section": "ui-coverage",
      "anchors": [
        "syntax"
      ],
      "path": "/llm/json/chunked/ui-coverage/configuration/attributefilters.json",
      "token_estimate": 332
    },
    {
      "id": "ui-coverage/configuration/attributefilters#options",
      "doc_id": "ui-coverage/configuration/attributefilters",
      "heading": "Options",
      "heading_level": 3,
      "content_markdown": "### Options\n\nWhether Cypress is allowed to use a certain attribute to identify an element when processing it for UI Coverage or Cypress Accessibility reports will be controlled by the **first** filter that matches the name and value of that attribute.\n\nThis means that catch-all rules can be added at the bottom of the list by setting `include` to `false`, and exceptions can be defined earlier in the list using `include: true`. For example, you could avoid all use of `aria-label` for identification of elements as a catch-call filter, but then define exceptions for certain values it may have where it is a good identifier.\n\nAttributes that do not match any rules are included by default and used if needed, so `include: true` is only required for defining exceptions. If you want to make sure an attribute is preferred as an identifier when available, add it to your [attributeFilters](/llm/markdown/accessibility/configuration/attributefilters.md).\n\n| Option | Required | Default | Description |\n| --- | --- | --- | --- |\n| `attribute` | Required |  | A regex string to match attribute names |\n| `value` | Optional | `.*` | A regex string to match attribute values |\n| `include` | Optional | `true` | A boolean to specify whether the matched attribute should be included. |\n| `comment` | Optional |  | A comment describing the purpose of this filter rule. |\n",
      "section": "ui-coverage",
      "anchors": [
        "options"
      ],
      "path": "/llm/json/chunked/ui-coverage/configuration/attributefilters.json",
      "token_estimate": 308
    },
    {
      "id": "ui-coverage/configuration/attributefilters#examples",
      "doc_id": "ui-coverage/configuration/attributefilters",
      "heading": "Examples",
      "heading_level": 2,
      "content_markdown": "## Examples\n\n### Excluding common auto-generated ID values\n\nSome component libraries generate\n\n```\n{  \"attributeFilters\": [    {      \"attribute\": \"id\",      \"value\": \":r.*\",      \"include\": false    }  ]}\n```\n\n#### HTML\n\n```\n<body>  <button id=\":r11:\" name=\"my-button\">Button 1</button>  <button id=\":r12:\" name=\"other-button\">Button 2</button></body>\n```\n\n#### Element identifiers displayed\n\n```\n[name=\"my-button\"][name=\"other-button\"]\n```\n\n* * *\n\n### Filtering related dynamic attributes\n\nWhen filtering dynamic `id` attributes, you should also filter attributes that reference those IDs to prevent elements from being identified by these related dynamic values. Common relationships include:\n\n*   Form associations (`for` attributes on labels)\n*   ARIA relationships (`aria-labelledby`, `aria-describedby`, `aria-controls`, `aria-owns`, `aria-details`)\n*   Name attributes that may mirror IDs in certain frameworks\n\n```\n{  \"attributeFilters\": [    {      \"attribute\": \"id|for|name|aria-.*\",      \"value\": \"dynamic-.*\",      \"include\": false    }  ]}\n```\n\n#### HTML\n\n```\n<div>  <label for=\"dynamic-input-1\">First Name</label>  <input id=\"dynamic-input-1\" name=\"dynamic-input-1\" aria-describedby=\"dynamic-help-1\" />  <p id=\"dynamic-help-1\">Enter your first name</p></div>\n```\n\n#### Element identifiers displayed\n\n```\nlabelinputp\n```\n\n### Excluding auto-generated attribute names\n\n```\n{  \"attributeFilters\": [    {      \"attribute\": \"ng-include-me\",      \"value\": \".*\",      \"include\": true    },    {      \"attribute\": \"ng-.*|_ng.*\",      \"value\": \".*\",      \"include\": false    }  ]}\n```\n\n#### HTML\n\n```\n<body>  <button ng-include-me=\"my-button\">Button 1</button>  <button ng-but-not-me=\"other-button\">Button 2</button></body>\n```\n\n#### Element identifiers displayed\n\n```\n[ng-include-me=\"my-button\"]:nth-child(2)\n```\n\n### Ignoring dynamic attributes for accurate grouping\n\n```\n{  \"attributeFilters\": [    {      \"attribute\": \"data-cy\",      \"value\": \"user-\\\\d+\",      \"include\": false    }  ]}\n```\n\n#### HTML\n\n```\n<button data-cy=\"user-123\" class=\"user\">Harper</button><button data-cy=\"user-456\" class=\"user\">Amara</button>\n```\n\n#### Element identifiers displayed\n\n```\n.user (2 instances)\n```\n",
      "section": "ui-coverage",
      "anchors": [
        "examples"
      ],
      "path": "/llm/json/chunked/ui-coverage/configuration/attributefilters.json",
      "token_estimate": 307
    },
    {
      "id": "ui-coverage/configuration/attributefilters#excluding-common-auto-generated-id-values",
      "doc_id": "ui-coverage/configuration/attributefilters",
      "heading": "Excluding common auto-generated ID values",
      "heading_level": 3,
      "content_markdown": "### Excluding common auto-generated ID values\n\nSome component libraries generate\n\n```\n{  \"attributeFilters\": [    {      \"attribute\": \"id\",      \"value\": \":r.*\",      \"include\": false    }  ]}\n```\n\n#### HTML\n\n```\n<body>  <button id=\":r11:\" name=\"my-button\">Button 1</button>  <button id=\":r12:\" name=\"other-button\">Button 2</button></body>\n```\n\n#### Element identifiers displayed\n\n```\n[name=\"my-button\"][name=\"other-button\"]\n```\n\n* * *\n",
      "section": "ui-coverage",
      "anchors": [
        "excluding-common-auto-generated-id-values"
      ],
      "path": "/llm/json/chunked/ui-coverage/configuration/attributefilters.json",
      "token_estimate": 63
    },
    {
      "id": "ui-coverage/configuration/attributefilters#filtering-related-dynamic-attributes",
      "doc_id": "ui-coverage/configuration/attributefilters",
      "heading": "Filtering related dynamic attributes",
      "heading_level": 3,
      "content_markdown": "### Filtering related dynamic attributes\n\nWhen filtering dynamic `id` attributes, you should also filter attributes that reference those IDs to prevent elements from being identified by these related dynamic values. Common relationships include:\n\n*   Form associations (`for` attributes on labels)\n*   ARIA relationships (`aria-labelledby`, `aria-describedby`, `aria-controls`, `aria-owns`, `aria-details`)\n*   Name attributes that may mirror IDs in certain frameworks\n\n```\n{  \"attributeFilters\": [    {      \"attribute\": \"id|for|name|aria-.*\",      \"value\": \"dynamic-.*\",      \"include\": false    }  ]}\n```\n\n#### HTML\n\n```\n<div>  <label for=\"dynamic-input-1\">First Name</label>  <input id=\"dynamic-input-1\" name=\"dynamic-input-1\" aria-describedby=\"dynamic-help-1\" />  <p id=\"dynamic-help-1\">Enter your first name</p></div>\n```\n\n#### Element identifiers displayed\n\n```\nlabelinputp\n```\n",
      "section": "ui-coverage",
      "anchors": [
        "filtering-related-dynamic-attributes"
      ],
      "path": "/llm/json/chunked/ui-coverage/configuration/attributefilters.json",
      "token_estimate": 129
    },
    {
      "id": "ui-coverage/configuration/attributefilters#excluding-auto-generated-attribute-names",
      "doc_id": "ui-coverage/configuration/attributefilters",
      "heading": "Excluding auto-generated attribute names",
      "heading_level": 3,
      "content_markdown": "### Excluding auto-generated attribute names\n\n```\n{  \"attributeFilters\": [    {      \"attribute\": \"ng-include-me\",      \"value\": \".*\",      \"include\": true    },    {      \"attribute\": \"ng-.*|_ng.*\",      \"value\": \".*\",      \"include\": false    }  ]}\n```\n\n#### HTML\n\n```\n<body>  <button ng-include-me=\"my-button\">Button 1</button>  <button ng-but-not-me=\"other-button\">Button 2</button></body>\n```\n\n#### Element identifiers displayed\n\n```\n[ng-include-me=\"my-button\"]:nth-child(2)\n```\n",
      "section": "ui-coverage",
      "anchors": [
        "excluding-auto-generated-attribute-names"
      ],
      "path": "/llm/json/chunked/ui-coverage/configuration/attributefilters.json",
      "token_estimate": 60
    },
    {
      "id": "ui-coverage/configuration/attributefilters#ignoring-dynamic-attributes-for-accurate-grouping",
      "doc_id": "ui-coverage/configuration/attributefilters",
      "heading": "Ignoring dynamic attributes for accurate grouping",
      "heading_level": 3,
      "content_markdown": "### Ignoring dynamic attributes for accurate grouping\n\n```\n{  \"attributeFilters\": [    {      \"attribute\": \"data-cy\",      \"value\": \"user-\\\\d+\",      \"include\": false    }  ]}\n```\n\n#### HTML\n\n```\n<button data-cy=\"user-123\" class=\"user\">Harper</button><button data-cy=\"user-456\" class=\"user\">Amara</button>\n```\n\n#### Element identifiers displayed\n\n```\n.user (2 instances)\n```\n",
      "section": "ui-coverage",
      "anchors": [
        "ignoring-dynamic-attributes-for-accurate-grouping"
      ],
      "path": "/llm/json/chunked/ui-coverage/configuration/attributefilters.json",
      "token_estimate": 52
    }
  ]
}