Test ID Naming Convention

June 30, 2026 · View on GitHub

All interactive and identifiable elements across the webcomponents library carry a data-testid attribute. This document defines the naming convention, explains how dynamic IDs are constructed, and lists every stable test ID by component.


Convention rules

  • Format: kebab-case strings only — dashboard-save-btn, not dashboardSaveBtn or dashboard_save_btn.
  • Prefix: each component owns a namespace prefix that matches its tag name without the mfp- scope — generic-table-card-*, dashboard-*, etc.
  • Static IDs describe purpose, not appearance: dashboard-save-btn instead of dashboard-green-button.
  • Dynamic IDs embed a runtime value (index, field name, card ID) separated by -. The pattern is always {prefix}-{runtime-value} or {prefix}-{runtime-value}-{suffix}.
  • Mutually exclusive branches may share an ID string (e.g. dashboard-edit-view-btn in both editButtonFirst branches) because only one is rendered at a time — a single getByTestId call always resolves to exactly one element.
  • Angular @Input testId — sub-components that accept a testId input render it as data-testid on their root element. The parent passes a derived value (testId() + '-secret', etc.) so the resulting attribute follows the same {prefix}-{suffix} pattern.

Component test IDs

DeclarativeTableCard (generic-table-card-*)

Elementdata-testidNotes
Card rootgeneric-table-cardStatic
Search buttongeneric-table-card-search-btnPresent when config.resourcesSearchable is true
Search inputgeneric-table-card-search-inputPresent when search is expanded
Create buttongeneric-table-card-create-btnPresent when createResourceFormConfig is set
Create dialoggeneric-table-card-create-dialog
Create confirmgeneric-table-card-create-confirm
Create cancelgeneric-table-card-create-cancel
Edit dialoggeneric-table-card-edit-dialogPresent when editResourceFormConfig is set
Edit confirmgeneric-table-card-edit-confirm
Edit cancelgeneric-table-card-edit-cancel
Delete dialoggeneric-table-card-delete-dialogPresent when deleteResourceConfirmationConfig is set
Delete confirmgeneric-table-card-delete-confirm
Delete cancelgeneric-table-card-delete-cancel

DeclarativeTable (generic-table-*)

Elementdata-testidNotes
Table elementgeneric-tableStatic
Header cellgeneric-table-header-{column}column = group.name or property
Table rowgeneric-table-row-{i}i = 0-based row index
Cell (simple)generic-table-cell-{i}-{property}property = column property field
Cell (group)generic-table-cell-{i}-{group}group = group.name
Group sub-valuegeneric-table-cell-{i}-{group}-{property}Nested field inside a grouped column
No-data stategeneric-table-view-nodataShown when resources is empty
Load-moregeneric-table-growingShown when hasMore is true
Page-size selectgeneric-table-pagination-selectAlways present

DeclarativeForm (generic-form-*)

Elementdata-testidNotes
Form elementgeneric-formStatic
Field containergeneric-form-field-container-{name}name = field.name (dot notation, e.g. metadata.name)
Field labelgeneric-form-field-label-{name}
Input or selectgeneric-form-field-{name}<ui5-input> or <ui5-select> depending on field.values
Select optiongeneric-form-field-{name}-option-{value}value = option string or empty for the blank placeholder

Dashboard (dashboard-*)

Main component

Elementdata-testidNotes
Root containerdashboardStatic
Titledashboard-titlePresent when config.title is set
Descriptiondashboard-descriptionPresent when config.description is set
Edit-cards buttondashboard-edit-cards-btnVisible in edit mode
Compact menu toggledashboard-toolbar-menu-btnVisible in compact toolbar mode
Compact dropdown menudashboard-toolbar-menu
Edit-view menu itemdashboard-action-edit-viewInside compact menu when config.editable is true
Custom action (menu item)dashboard-action-{action}action = customAction.action; in compact menu
Custom action (button)dashboard-action-{action}Same value, rendered as <ui5-button> in full toolbar
Edit-view buttondashboard-edit-view-btnFull toolbar; appears before or after custom actions depending on editButtonFirst
Griddashboard-gridThe gridstack container
Save buttondashboard-save-btnVisible in edit mode
Cancel buttondashboard-cancel-btnVisible in edit mode

DashboardCard

Elementdata-testidNotes
Card rootdashboard-card-{id}id = card.id; both component-card and card branches
Remove buttondashboard-card-{id}-removeVisible in edit mode

DashboardSection

Elementdata-testidNotes
Section rootdashboard-section-{id}id = section.id
Remove buttondashboard-section-{id}-removeVisible in edit mode when section.editable !== false
Section titledashboard-section-{id}-titlePresent when section.title is set

EditCardsDialog

Elementdata-testidNotes
Dialogdashboard-edit-cards-dialog
Card rowdashboard-edit-cards-row-{id}id = availableCard.id
Toggle switchdashboard-edit-cards-switch-{id}
Save buttondashboard-edit-cards-save-btn
Cancel buttondashboard-edit-cards-cancel-btn

DiscardChangesDialog

Elementdata-testidNotes
Dialogdashboard-discard-changes-dialog
Confirm (Discard) buttondashboard-discard-changes-confirm-btn
Cancel buttondashboard-discard-changes-cancel-btn

UnsavedChangesDialog

Elementdata-testidNotes
Dialogdashboard-unsaved-changes-dialog
Save buttondashboard-unsaved-changes-save-btn
Discard buttondashboard-unsaved-changes-discard-btn
Cancel buttondashboard-unsaved-changes-cancel-btn

ResourceField (resource-field-*)

ResourceField derives its test ID from fieldDefinition.property at runtime:

data-testid = "resource-field-{property}"

Sub-elements follow a consistent suffix pattern:

Elementdata-testidCondition
Root spanresource-field-{property}Always
Secret valueresource-field-{property}-secretdisplayAs: 'secret'
Show/hide toggleresource-field-{property}-secret-toggledisplayAs: 'secret'
Boolean iconresource-field-{property}-booleandisplayAs: 'boolIcon' and value is "true" / "false"
Linkresource-field-{property}-linkdisplayAs: 'link' and value is a valid URL
Tooltip iconresource-field-{property}-tooltipdisplayAs: 'tooltip'
Alert iconresource-field-{property}-icondisplayAs: 'alert' and value is falsy
Action buttonresource-field-{property}-buttondisplayAs: 'button'
Copy iconresource-field-{property}-copyuiSettings.withCopyButton: true
Tag listresource-field-{property}-tagsdisplayAs: 'tag'

Example — a field { property: 'status.ready', uiSettings: { displayAs: 'boolIcon' } } on a resource where the value is "true" produces:

<span data-testid="resource-field-status.ready">
  <!-- mfp-boolean-value renders: -->
  <ui5-icon data-testid="resource-field-status.ready-boolean" ... />
</span>

Adding test IDs to new components

When contributing a new component:

  1. Pick a namespace prefix that matches the component's tag (without mfp-).
  2. Add data-testid to every interactive element (buttons, inputs, selects, links, dialogs) and every major container that E2E tests would use as an anchor.
  3. Use [attr.data-testid] for dynamic values and plain data-testid="..." for static ones.
  4. Document the test IDs in the component's docs/ file under a ## Test IDs section, following the table format used in this guide.
  5. Add the new IDs to the table in this file.