Element Identification
UI Coverage uniquely identifies elements across views and snapshots using a combination of HTML attributes, location, and other signals in the DOM. Stable and unique identifiers are crucial for accurately tracking and de-duplicating elements throughout the various snapshots captured in your tests.
Significant attributes for identification​
Certain attributes are prioritized by UI Coverage for element identification and grouping. These include:
data-cy
data-test
data-testid
data-test-id
data-qa
row-id
id
name
By using these attributes consistently in your application, you can improve the accuracy of UI Coverage tracking.
Configuring element identification​
Attribute filters​
Exclude irrelevant or dynamically generated attributes to reduce noise in UI Coverage reports. For example:
{
"uiCoverage": {
"attributeFilters": [
{
"attribute": "id",
"value": ":r.*:",
"include": false
}
]
}
}
Learn more about attribute filtering in the Attribute Filters guide.
Significant attributes​
Define custom significant attributes to prioritize specific selectors that align with your application’s structure. For example:
{
"uiCoverage": {
"significantAttributes": ["data-custom-id"]
}
}
Refer to the Significant Attributes guide for detailed instructions.