/kibana-testing-tools:test-selector-healerfrom kibana-testing-tools
Fix failing Cypress/Scout/Playwright tests by adding missing data-test-subj attributes to UI source components when no reliable selector exists. Use when tests fail due to brittle selectors, strict mode violations from ambiguous locators, elements not found, or when debugging tests that rely on CSS classes, DOM structure, or text content that changes. Triggers on "no selector", "strict mode violation", "element not found", "brittle selector", "add test subject", "data-test-subj".
Ships in kibana-testing-tools. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Fix test failures at their root by adding data-test-subj attributes to UI source code when tests lack reliable selectors. Modifying the application source is the correct fix — not piling up fragile CSS selectors or .first() / .nth() workarounds in test code.
Activate when a test failure matches ANY of these patterns:
resolved to 5 elements).euiButton), DOM structure (div > span), or text content (getByText) that breaks on UI changes.first() / .nth() as workaround for missing specificityTest fails with selector issue
│
├─ Does a data-test-subj already exist for this element?
│ ├─ YES → Use it. Fix the test selector, not the component.
│ └─ NO → Continue below.
│
├─ Is the element in YOUR codebase (not a third-party lib)?
│ ├─ YES → Add data-test-subj to the component. Then fix the test.
│ └─ NO → Use the best available stable selector (role, aria-label, etc.)
│
└─ Is this an EUI component?
├─ YES → EUI components accept data-test-subj as a prop. Add it.
└─ NO → Wrap the element in a <div data-test-subj="..."> or add the attribute directly.
camelCase for simple names: data-test-subj="osqueryResultsTable"data-test-subj="save-pack-button"data-test-subj={play-${item.name}-button}osquery, fleet, securitysavedQueryFlyoutSaveButton not btn1React component with props interface:
interface MyComponentProps {
'data-test-subj'?: string;
// ... other props
}
const MyComponent: React.FC<MyComponentProps> = ({
'data-test-subj': dataTestSubj,
...rest
}) => (
<div data-test-subj={dataTestSubj}>
{/* ... */}
</div>
);
EUI components (already support it):
// EUI components accept data-test-subj directly
<EuiButton data-test-subj="submitQueryButton" onClick={handleSubmit}>
Submit
</EuiButton>
<EuiFieldText data-test-subj="queryNameInput" value={name} onChange={onChange} />
<EuiBasicTable data-test-subj="packsTable" items={items} columns={columns} />
Wrapper div for structural grouping:
<div data-test-subj="ecsMappingRow">
<EcsFieldInput />
<OsqueryColumnInput />
<EuiButtonIcon aria-label="Delete ECS mapping row" />
</div>
Dynamic/list items:
{items.map((item) => (
<EuiTableRow key={item.id} data-test-subj={`pack-row-${item.name}`}>
{/* ... */}
</EuiTableRow>
))}
data-test-subj to every single element — only where tests need stable anchorsdata-test-subjRead the test error. Identify:
Search for the component that renders the target element:
Grep for the text content, existing partial selector, or component name
in the plugin's public/ directory
Common locations in Kibana plugins:
public/components/ — shared UI componentspublic/routes/ — page-level componentspublic/forms/ — form fields and editorspublic/shared_components/ — cross-feature UIApply the rules above. Prefer the minimal change:
data-test-subj in props, just pass it from the parentReplace the brittle selector with:
// Scout (Playwright)
page.testSubj.locator('myNewTestSubject')
// Cypress
cy.getBySel('myNewTestSubject')
// Primary — data-test-subj via Scout helper
page.testSubj.locator('osqueryResultsTable')
// With chaining
page.testSubj.locator('packsTable').locator('[aria-label="Edit"]')
// Dynamic
page.testSubj.locator(`play-${packName}-button`)
// Primary
cy.getBySel('osqueryResultsTable')
// Dynamic
cy.getBySel(`play-${packName}-button`)
All EUI components pass through data-test-subj. Key ones:
EuiButton, EuiButtonIcon, EuiButtonEmpty — action buttonsEuiFieldText, EuiFieldNumber, EuiTextArea — form inputsEuiComboBox — combobox (use parent data-test-subj + inner comboBoxSearchInput)EuiBasicTable, EuiInMemoryTable — tablesEuiAccordion — collapsible sectionsEuiFlyout — slide-out panelsEuiModal — dialogsEuiTab, EuiTabs — tab navigationEuiSwitch, EuiCheckbox — togglesBefore (brittle — fails when text changes or multiple buttons exist):
await page.getByText('Submit').first().click();
Step 1 — Find the component:
// public/live_queries/form/index.tsx
<EuiButton onClick={handleSubmit} fill>Submit</EuiButton>
Step 2 — Add data-test-subj:
<EuiButton data-test-subj="submitLiveQueryButton" onClick={handleSubmit} fill>
Submit
</EuiButton>
Step 3 — Update the test:
await page.testSubj.locator('submitLiveQueryButton').click();
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub patrykkopycinski/patryks-treadmill-claude-plugins --plugin kibana-testing-toolsOther plugins' skills for the same job
9 skills in this plugin
/api-test-generatorAuto-generate comprehensive Scout API tests from Kibana route definitions, including valid/invalid request tests, RBAC tests, and schema-driven test data generation./cypress-to-scout-migratorStrategic test suite optimizer for Cypress→Scout migration. Analyzes entire test coverage, identifies blind spots, refactors for performance and DRY principles, then generates optimized Scout suites. Not a 1:1 converter.
/flake-hunterIdentify, debug, and fix flaky tests systematically by detecting root causes, applying targeted fixes, and verifying stability to eliminate intermittent CI failures.