packages/grafana-e2e-selectors/src/selectors/README.md
The selectors defined in pages.ts and components.ts are versioned. A versioned selector consists of an object literal where value is the selector context and key is the minimum Grafana version for which the value is valid. The versioning is important in plugin end-to-end testing, as it allows them to resolve the right selector values for a given Grafana version.
const components = {
PanelEditor: {
content: {
'11.1.0': 'data-testid Panel editor content', // resolved for Grafana >= 11.1.0
'9.5.0': 'Panel editor content', // resolved for Grafana >= 9.5.0 <11.1.0
},
}
...
}
A few things to keep in mind:
pages.Dashboard.url('ud73s9') is fine.
components.Panels.Panel.title('Panel header') is bad.git show main:package.json | awk -F'"' '/"version": ".+"/{ print $4; exit; }'), but if you know in advance that your change will be backported you can specify the version of the release with the lowest version number. The version you specify should not include tags such as -pre or build number.[!CAUTION] If you're changing a part of the UI that already has a selector defined, you should reuse the existing selector to avoid breaking end-to-end tests in plugins.
git show main:package.json | awk -F'"' '/"version": ".+"/{ print $4; exit; }'). The version you specify should not include tags such as -pre or build number.selectors.components.Panels.Panel.title('Header') require context awareness which makes them hard to use in end-to-end tests.